From 0e94fe354fc4a125e90bb193ae40af6b81bfc140 Mon Sep 17 00:00:00 2001 From: radhakrishnan Date: Tue, 22 Jul 2025 20:21:06 +0530 Subject: [PATCH] Fix EMF to PNG conversion issue #362 - Add EMF-specific handling in ImageMagick converter to avoid LibreOffice delegate issues - Disable EMF delegate and set proper conversion parameters (density: 300, background: white, alpha: remove) - Prioritize Inkscape over ImageMagick for EMF files as it handles them natively - Resolves LibreOffice delegate command failures when converting EMF files Fixes #362 --- src/converters/imagemagick.ts | 7 +++++++ src/converters/main.ts | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/converters/imagemagick.ts b/src/converters/imagemagick.ts index 4122a24..e3959f8 100644 --- a/src/converters/imagemagick.ts +++ b/src/converters/imagemagick.ts @@ -460,6 +460,13 @@ export function convert( } } + // Handle EMF files specifically to avoid LibreOffice delegate issues + if (fileType === "emf") { + // Use direct conversion without delegates for EMF files + inputArgs = ["-define", "emf:delegate=false", "-density", "300"]; + outputArgs = ["-background", "white", "-alpha", "remove"]; + } + return new Promise((resolve, reject) => { execFile( "magick", diff --git a/src/converters/main.ts b/src/converters/main.ts index a9f2e42..1726f44 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -47,6 +47,11 @@ const properties: Record< ) => unknown; } > = { + // Prioritize Inkscape for EMF files as it handles them better than ImageMagick + inkscape: { + properties: propertiesInkscape, + converter: convertInkscape, + }, libjxl: { properties: propertiesLibjxl, converter: convertLibjxl, @@ -87,10 +92,6 @@ const properties: Record< properties: propertiesGraphicsmagick, converter: convertGraphicsmagick, }, - inkscape: { - properties: propertiesInkscape, - converter: convertInkscape, - }, assimp: { properties: propertiesassimp, converter: convertassimp,