Skip to content

Commit 0e94fe3

Browse files
gingeekrishnaC4illin
authored andcommitted
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
1 parent fe22b2f commit 0e94fe3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/converters/imagemagick.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ export function convert(
460460
}
461461
}
462462

463+
// Handle EMF files specifically to avoid LibreOffice delegate issues
464+
if (fileType === "emf") {
465+
// Use direct conversion without delegates for EMF files
466+
inputArgs = ["-define", "emf:delegate=false", "-density", "300"];
467+
outputArgs = ["-background", "white", "-alpha", "remove"];
468+
}
469+
463470
return new Promise((resolve, reject) => {
464471
execFile(
465472
"magick",

src/converters/main.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const properties: Record<
4747
) => unknown;
4848
}
4949
> = {
50+
// Prioritize Inkscape for EMF files as it handles them better than ImageMagick
51+
inkscape: {
52+
properties: propertiesInkscape,
53+
converter: convertInkscape,
54+
},
5055
libjxl: {
5156
properties: propertiesLibjxl,
5257
converter: convertLibjxl,
@@ -87,10 +92,6 @@ const properties: Record<
8792
properties: propertiesGraphicsmagick,
8893
converter: convertGraphicsmagick,
8994
},
90-
inkscape: {
91-
properties: propertiesInkscape,
92-
converter: convertInkscape,
93-
},
9495
assimp: {
9596
properties: propertiesassimp,
9697
converter: convertassimp,

0 commit comments

Comments
 (0)