Skip to content

Commit cd9af08

Browse files
committed
Fix macOS/Linux compatibility by using dynamic ExifTool imports
Fixes #3 The extension was failing to activate on macOS/Linux because the top-level import of 'exiftool-vendored' would crash when the platform-specific binary (exiftool-vendored.pl) was not found in the bundled package. Changes: - Replace top-level import with dynamic import using async/await - Wrap ExifTool initialization in try-catch to allow graceful fallback - Extension now properly falls back to system-installed ExifTool on macOS/Linux - Update README with clear installation requirements for each platform - Add CHANGELOG.md to track version changes - Bump version to 0.1.1 This allows users who have ExifTool installed via Homebrew (macOS) or their package manager (Linux) to use the extension without bundling large platform- specific binaries (~100MB combined).
1 parent 5f311f9 commit cd9af08

File tree

5 files changed

+65
-39
lines changed

5 files changed

+65
-39
lines changed

CHANGELOG.md

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,53 @@
1-
# Change Log
1+
# Changelog
22

3-
## [0.1.0] - 2025-09-19
3+
All notable changes to the "Image Metadata Inspector" extension will be documented in this file.
44

5-
### Added
6-
- **Enhanced cross-platform support**: Improved compatibility for macOS and Linux with native ExifTool fallback
7-
- **JPEG file support**: Added support for .jpeg file extension
8-
- **Better error handling**: Clear error messages and platform-specific guidance
9-
- **Platform detection**: Detailed debugging information showing platform and version details
10-
- **Marketplace metadata**: Added keywords, license, and publisher information for VS Code Marketplace
11-
- **Packaging support**: Added vsce scripts for marketplace publishing
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
127

13-
### Changed
14-
- **Improved initialization**: Better ExifTool initialization with graceful fallback mechanisms
15-
- **Enhanced logging**: More detailed output messages for troubleshooting cross-platform issues
16-
- **Updated dependencies**: Cross-platform compatible dependency configuration
17-
- **Professional documentation**: Comprehensive README and installation instructions
8+
## [0.1.1] - 2025-10-31
189

1910
### Fixed
20-
- **Launch configuration**: Fixed VS Code development environment setup
21-
- **Extension activation**: Improved extension loading and error recovery
22-
- **Windows-only limitation**: Added fallback support for other platforms (testing needed)
23-
- **Node.js compatibility**: Updated packaging for modern Node.js versions
11+
- Fixed macOS/Linux compatibility issue where extension would fail to activate due to missing `exiftool-vendored.pl` binary
12+
- Extension now properly falls back to system-installed ExifTool on macOS/Linux when bundled binary is unavailable
2413

25-
### Notes
26-
- Cross-platform improvements are in place but need community testing on macOS/Linux
27-
- Please report any issues on non-Windows platforms via GitHub Issues
14+
### Changed
15+
- Changed ExifTool loading to use dynamic imports to prevent activation failures on unsupported platforms
16+
- Updated README with clearer installation instructions for macOS/Linux users
2817

29-
## [0.0.5] - 2023-11-13
18+
## [0.1.0] - 2024-09-19
3019

3120
### Added
32-
- New logging feature: Debug and informational messages are now logged to the VS Code Output console for better troubleshooting.
21+
- Initial cross-platform support attempt
22+
- Fallback mechanism to use native ExifTool when vendored version unavailable
3323

3424
### Changed
35-
- Enhanced `.gitignore` and `.vscodeignore` to keep the repository and `.vsix` package clean from development-specific files.
25+
- Improved error handling and logging
26+
- Enhanced output console messages for debugging
27+
28+
## [0.0.5] - 2024-11-13
29+
30+
### Added
31+
- Output console logging for better debugging
32+
- Platform detection and information display
3633

37-
## [0.0.4] - 2023-10-01
34+
## [0.0.4] - 2024-04-03
3835

3936
### Added
40-
- Support for JPG and WEBP files.
37+
- Support for WebP image format
38+
- Support for JPG/JPEG image formats
4139

42-
## [0.0.3] - 2023-09-15
40+
## [0.0.3] - 2024-03-XX
4341

4442
### Added
45-
- Initial release of Image Metadata Display.
43+
- Initial release
44+
- PNG metadata inspection
45+
- ComfyUI workflow metadata support
46+
- Right-click context menu integration
47+
- Command palette support
48+
- JSON prettification for metadata display
49+
50+
[0.1.1]: https://github.com/Gerkinfeltser/image-metadata-display/compare/v0.1.0...v0.1.1
51+
[0.1.0]: https://github.com/Gerkinfeltser/image-metadata-display/compare/v0.0.5...v0.1.0
52+
[0.0.5]: https://github.com/Gerkinfeltser/image-metadata-display/compare/v0.0.4...v0.0.5
53+
[0.0.4]: https://github.com/Gerkinfeltser/image-metadata-display/releases/tag/v0.0.4

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ This extension for Visual Studio Code allows users to view metadata of PNG, JPG,
4444
## Cross-Platform Support
4545

4646
- **Windows**: ✅ Fully supported with bundled ExifTool executable
47-
- **macOS**: ⚠️ Improved support with native ExifTool fallback (install with: `brew install exiftool`)
48-
- **Linux**: ⚠️ Improved support with native ExifTool fallback (install via package manager)
47+
- **macOS**: ✅ Requires ExifTool installed via Homebrew: `brew install exiftool`
48+
- **Linux**: ✅ Requires ExifTool installed via your package manager (e.g., `apt install exiftool`, `dnf install perl-Image-ExifTool`)
4949

50-
The extension automatically detects your platform and uses the best available method. **Note**: macOS and Linux support has been significantly improved but needs community testing. Please report any issues via GitHub Issues.
50+
The extension automatically detects your platform and uses the best available method:
51+
1. First attempts to use the bundled ExifTool (Windows)
52+
2. Falls back to system-installed ExifTool if bundled version is unavailable (macOS/Linux)
5153

5254
## Viewing Output Logs
5355

@@ -60,7 +62,8 @@ To view detailed logs and troubleshoot issues:
6062
## System Requirements
6163

6264
- Visual Studio Code version 1.87.0 or higher
63-
- For macOS/Linux: ExifTool installed system-wide (optional, but recommended)
65+
- **For macOS**: ExifTool must be installed via Homebrew (`brew install exiftool`)
66+
- **For Linux**: ExifTool must be installed via your package manager
6467

6568
## Supported File Types
6669

@@ -80,7 +83,7 @@ This extension was originally designed for ComfyUI users who want to:
8083
## Known Issues
8184

8285
- Workflow JSON extraction to separate files doesn't create working ComfyUI workflows (planned feature)
83-
- Some ExifTool features may require native installation on macOS/Linux
86+
- macOS/Linux users must have ExifTool installed system-wide for the extension to function
8487

8588
## Contributing
8689

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/Gerkinfeltser/image-metadata-display.git"
88
},
9-
"version": "0.1.0",
9+
"version": "0.1.1",
1010
"publisher": "Gerkinfeltser",
1111
"icon": "images/image_metadata_viewer_icon.png",
1212
"license": "MIT",

src/extension.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
import * as vscode from 'vscode';
2-
import { ExifTool } from 'exiftool-vendored';
32
import * as os from 'os';
43
import { exec } from 'child_process';
54
import { promisify } from 'util';
65

76
const execAsync = promisify(exec);
87
const outputChannel = vscode.window.createOutputChannel('Image Metadata Extension');
98

9+
// Lazy-load ExifTool to avoid import failures crashing the extension
10+
let ExifToolClass: any = null;
11+
async function loadExifToolClass() {
12+
if (!ExifToolClass) {
13+
try {
14+
const module = await import('exiftool-vendored');
15+
ExifToolClass = module.ExifTool;
16+
} catch (error) {
17+
outputChannel.appendLine(`Failed to import exiftool-vendored: ${error instanceof Error ? error.message : String(error)}`);
18+
throw error;
19+
}
20+
}
21+
return ExifToolClass;
22+
}
23+
1024
export function activate(context: vscode.ExtensionContext) {
1125
console.log("Debug: Image Metadata Extension is now active.");
1226
outputChannel.appendLine('Image Metadata Extension is now active!');
@@ -83,7 +97,7 @@ async function showMetadata(fileUri: vscode.Uri, viewColumn: vscode.ViewColumn)
8397
}
8498

8599
class MetadataProvider implements vscode.TextDocumentContentProvider {
86-
private exifTool: ExifTool | null = null;
100+
private exifTool: any = null;
87101
private useNativeExifTool: boolean = false;
88102
private initializationAttempted: boolean = false;
89103
private initializationError: string | null = null;
@@ -102,6 +116,7 @@ class MetadataProvider implements vscode.TextDocumentContentProvider {
102116

103117
try {
104118
// Try to initialize with exiftool-vendored first
119+
const ExifTool = await loadExifToolClass();
105120
this.exifTool = new ExifTool();
106121
outputChannel.appendLine('ExifTool (vendored) initialized successfully');
107122
return;
@@ -223,7 +238,7 @@ class MetadataProvider implements vscode.TextDocumentContentProvider {
223238

224239
dispose() {
225240
if (this.exifTool) {
226-
this.exifTool.end().catch(error => {
241+
this.exifTool.end().catch((error: Error) => {
227242
console.error('Error disposing ExifTool:', error);
228243
});
229244
}

0 commit comments

Comments
 (0)