{"record":{"id":"7e4b32174723d534","repo":"gchq/CyberChef","slug":"error-loading-image-err-7e4b32","errorCode":null,"errorMessage":"Error loading image. (${err})","messagePattern":"Error loading image\\. \\((.+?)\\)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"warning","filePath":"src/core/operations/ImageFilter.mjs","lineNumber":55,"sourceCode":"        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {byteArray}\n     */\n    async run(input, args) {\n        const [filterType] = args;\n        if (!isImage(input)) {\n            throw new OperationError(\"Invalid file type.\");\n        }\n\n        let image;\n        try {\n            image = await Jimp.read(input);\n        } catch (err) {\n            throw new OperationError(`Error loading image. (${err})`);\n        }\n        try {\n            if (isWorkerEnvironment())\n                self.sendStatusMessage(\n                    \"Applying \" +\n                        filterType.toLowerCase() +\n                        \" filter to image...\",\n                );\n            if (filterType === \"Greyscale\") {\n                image.greyscale();\n            } else {\n                image.sepia();\n            }\n\n            let imageBuffer;\n            if (image.mime === \"image/gif\") {\n                imageBuffer = await image.getBuffer(JimpMime.png);\n            } else {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ImageFilter.mjs#L37-L73","documentation":"Thrown when Jimp.read rejects inside Image Filter. Same shape as 413: magic bytes looked image-like but Jimp could not decode. The original error is embedded in the message.","triggerScenarios":"Truncated/corrupt image body, unsupported subformat, container masquerading as an image, oversized file exhausting memory.","commonSituations":"Partial download; conversion artefact; Jimp version missing a codec; very large image in a worker.","solutions":["Read the embedded Jimp error text for the precise cause.","Re-supply a complete, valid source image.","Pre-convert to PNG/JPEG externally.","Verify the bundled Jimp supports the image subformat."],"exampleFix":"// before\nop.run(truncatedBuf, [\"Sepia\"]);\n// after\nop.run(fullBuf, [\"Sepia\"]);","handlingStrategy":"try-catch","validationCode":"async function assertFilterJimpReadable(buf) {\n  try { await Jimp.read(buf); }\n  catch (e) { throw new Error(`Jimp cannot read this image: ${e}`); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  result = await filter.run(buf, [filterType]);\n} catch (e) {\n  if (e instanceof OperationError && /Error loading image/.test(e.message)) {\n    result = await filter.run(await reload(fullUrl), [filterType]);\n  } else throw e;\n}","preventionTips":["Supply a complete, valid source image.","Pre-convert unsupported subformats to PNG/JPEG.","Verify the bundled Jimp supports the format."],"tags":["image","jimp","decode-error","corrupt-file"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}