{"record":{"id":"ffc884cd307beff1","repo":"gchq/CyberChef","slug":"error-loading-image-err-ffc884","errorCode":null,"errorMessage":"Error loading image. (${err})","messagePattern":"Error loading image\\. \\((.+?)\\)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/BlurImage.mjs","lineNumber":63,"sourceCode":"    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {byteArray}\n     */\n    async run(input, args) {\n        const [blurAmount, blurType] = args;\n\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            switch (blurType) {\n                case \"Fast\":\n                    if (isWorkerEnvironment())\n                        self.sendStatusMessage(\"Fast blurring image...\");\n                    image.blur(blurAmount);\n                    break;\n                case \"Gaussian\":\n                    if (isWorkerEnvironment())\n                        self.sendStatusMessage(\"Gaussian blurring image...\");\n                    image.gaussian(blurAmount);\n                    break;\n            }\n\n            let imageBuffer;\n            if (image.mime === \"image/gif\") {\n                imageBuffer = await image.getBuffer(JimpMime.png);","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/BlurImage.mjs#L45-L81","documentation":"After the isImage() pre-check passes, the operation calls Jimp.read(input). If Jimp cannot decode the buffer (unsupported codec, truncated data, or a false-positive magic byte), the catch block rethrows as OperationError with the underlying error message.","triggerScenarios":"Jimp.read() rejects: input passes the rough isImage check but is corrupt or uses a format/variant Jimp's decoder cannot handle.","commonSituations":"Truncated image download; progressive/animated formats; exotic color profiles; file that starts with image magic bytes but is otherwise invalid.","solutions":["Open the file in an image viewer to confirm it is intact.","Re-encode the image to PNG/JPEG before passing it to BlurImage.","Inspect err.message from the thrown OperationError for the specific decoder failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await blurImage.run(input, args); }\ncatch (e) { if (/Error loading image/.test(e.message)) { /* re-encode to PNG upstream */ } else throw e; }","preventionTips":["Re-encode untrusted images to PNG/JPEG before processing.","Verify the file opens in a standard viewer first.","Inspect the embedded err.message for the Jimp decoder cause."],"tags":["image","jimp","decode","blur"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}