From 8879f40be54cf216f4b1402c3f37cffcfed803c8 Mon Sep 17 00:00:00 2001 From: Jarvis Date: Mon, 8 Sep 2025 10:55:27 +0200 Subject: [PATCH] fix: update ImageMagick to use 'magick' instead of deprecated 'convert' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update default ImageMagick executable from 'convert' to 'magick' in constants - Remove deprecated 'convert' subcommand from ImageMagick spawn calls - Update UI labels and settings descriptions to reflect 'magick' command - Fix pdf2img PATH environment to include Node.js installation paths This resolves ImageMagick v7 deprecation warning and fixes pdf2img execution failure caused by missing Node.js in PATH. The 'convert' command was deprecated in ImageMagick v7 in favor of the unified 'magick' command. Fixes: "env: node: No such file or directory" error in pdf2img execution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- main.ts | 6 +++--- src/converters/PdfToImageConverter.ts | 17 +++++++++++++---- src/core/constants.ts | 2 +- src/core/settings.ts | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/main.ts b/main.ts index 1a869e7..4ade2ba 100644 --- a/main.ts +++ b/main.ts @@ -1437,10 +1437,10 @@ class ObsidianTypstPDFExportSettingTab extends PluginSettingTab { })); new Setting(containerEl) - .setName('ImageMagick convert path') - .setDesc('Path to ImageMagick convert executable (leave empty to use system PATH)') + .setName('ImageMagick path') + .setDesc('Path to ImageMagick executable (leave empty to use system PATH)') .addText(text => text - .setPlaceholder('convert') + .setPlaceholder('magick') .setValue(this.plugin.settings.executablePaths.imagemagickPath) .onChange(async (value) => { if (!SecurityUtils.validateExecutablePath(value)) { diff --git a/src/converters/PdfToImageConverter.ts b/src/converters/PdfToImageConverter.ts index 043df56..aeb10e3 100644 --- a/src/converters/PdfToImageConverter.ts +++ b/src/converters/PdfToImageConverter.ts @@ -180,11 +180,21 @@ export class PdfToImageConverter { const additionalPaths = this.plugin?.settings?.executablePaths?.additionalPaths || ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin']; + // Ensure Node.js paths are included for pdf2img execution + const nodePaths = [ + '/usr/local/bin', // Common Node.js installation + '/opt/homebrew/bin', // Homebrew on macOS + '/usr/bin', // System Node.js + '/usr/local/node/bin' // Alternative Node.js location + ]; + const env = { ...process.env, - PATH: process.env.PATH + (additionalPaths.length > 0 - ? ':' + additionalPaths.join(':') - : '') + PATH: [ + process.env.PATH, + ...nodePaths, + ...additionalPaths + ].filter(Boolean).join(':') }; const result = await execAsync(cliCommand, { @@ -263,7 +273,6 @@ export class PdfToImageConverter { // Use ImageMagick to convert PNG to JPEG const convertProcess = spawn('magick', [ - 'convert', actualOutputPath, '-quality', opts.quality.toString(), finalOutputPath diff --git a/src/core/constants.ts b/src/core/constants.ts index 93594cd..7073de4 100644 --- a/src/core/constants.ts +++ b/src/core/constants.ts @@ -49,7 +49,7 @@ export const DEPENDENCY_CONSTANTS = { DEFAULT_EXECUTABLES: { pandoc: 'pandoc', typst: 'typst', - imagemagick: 'convert' + imagemagick: 'magick' }, /** diff --git a/src/core/settings.ts b/src/core/settings.ts index 154734a..add9f92 100644 --- a/src/core/settings.ts +++ b/src/core/settings.ts @@ -19,7 +19,7 @@ export interface obsidianTypstPDFExportSettings { /** Executable paths configuration */ executablePaths: { - /** Path to ImageMagick convert command (optional, uses PATH if not specified) */ + /** Path to ImageMagick command (optional, uses PATH if not specified) */ imagemagickPath: string; /** Additional paths to append to PATH environment variable */ additionalPaths: string[];