The next-generation file converter. Open source, fully local* and free forever.
fix: imagemagick format conversion failures
Maya058f16af6134
diff --git a/src/lib/converters/magick/magick-automated.ts b/src/lib/converters/magick/magick-automated.tsindex 0968c21..e832525 100644--- a/src/lib/converters/magick/magick-automated.ts+++ b/src/lib/converters/magick/magick-automated.ts@@ -97,7 +97,6 @@ export const imageFormats = [new FormatInfo("png64", true, true),new FormatInfo("png8", true, true),new FormatInfo("ps", false, true),- new FormatInfo("ps1", false, true),new FormatInfo("ps2", false, true),new FormatInfo("ps3", false, true),new FormatInfo("psb", true, true),diff --git a/src/lib/workers/magick.ts b/src/lib/workers/magick.tsindex a9cc4f7..59a4c86 100644--- a/src/lib/workers/magick.ts+++ b/src/lib/workers/magick.ts@@ -55,9 +55,11 @@ const handleMessage = async (message.to = message.to.toLowerCase();if (message.to === ".jfif") message.to = ".jpeg";+ let to = message.input.to;let from = message.input.from;if (from === ".jfif") from = ".jpeg";if (from === ".fit") from = ".fits";+ if (to === ".fit") to = ".fits";console.log(JSON.stringify(message, null, 2));const conversionSettings = JSON.parse(@@ -67,38 +69,12 @@ const handleMessage = async (const specialResult = await handleSpecialOutput(from,- message.to,+ to,buffer,conversionSettings,);if (specialResult) return specialResult;- // build frames of animated formats (webp/gif)- // APNG does not work on magick-wasm since it needs ffmpeg built-in (not in magick-wasm) - handle in ffmpeg- if (- (from === ".webp" || from === ".gif") &&- (message.to === ".gif" || message.to === ".webp")- ) {- const collection = MagickImageCollection.create(- new Uint8Array(buffer),- );- const format =- message.to === ".gif"- ? MagickFormat.Gif- : MagickFormat.WebP;- const result = await new Promise<Uint8Array>((resolve) => {- collection.write(format, (output) => {- resolve(structuredClone(output));- });- });- collection.dispose();-- return {- type: "finished",- output: result,- };- }-const parsedInput = await handleSpecialInput(from, buffer);const img = parsedInput? MagickImage.create(@@ -112,11 +88,7 @@ const handleMessage = async (}),);- const converted = await magickConvert(- img,- message.to,- conversionSettings,- );+ const converted = await magickConvert(img, to, conversionSettings);return {type: "finished",@@ -183,6 +155,27 @@ const handleSpecialOutput = async (buffer: ArrayBuffer,conversionSettings: ConversionSettings,): Promise<Partial<WorkerMessage> | null> => {+ // build frames of animated formats (webp/gif)+ // APNG does not work on magick-wasm since it needs ffmpeg built-in (not in magick-wasm) - handle in ffmpeg+ if (+ (from === ".webp" || from === ".gif") &&+ (to === ".gif" || to === ".webp")+ ) {+ const collection = MagickImageCollection.create(new Uint8Array(buffer));+ const format = to === ".gif" ? MagickFormat.Gif : MagickFormat.WebP;+ const result = await new Promise<Uint8Array>((resolve) => {+ collection.write(format, (output) => {+ resolve(structuredClone(output));+ });+ });+ collection.dispose();++ return {+ type: "finished",+ output: result,+ };+ }+if (from === ".ico") {const imgs = MagickImageCollection.create();imgs.read(@@ -225,7 +218,7 @@ const handleSpecialOutput = async (}if (from === ".ani") {- console.log("Parsing ANI file");+ console.log("Parsing ANI file");try {const { parseAni } = await loadAniHelpers();const parsedAni = parseAni(new Uint8Array(buffer));