{"record":{"id":"6de1e120b218fb78","repo":"gchq/CyberChef","slug":"error-blurring-image-err","errorCode":null,"errorMessage":"Error blurring image. (${err})","messagePattern":"Error blurring image\\. \\((.+?)\\)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/BlurImage.mjs","lineNumber":87,"sourceCode":"                        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);\n            } else {\n                imageBuffer = await image.getBuffer(image.mime);\n            }\n            return imageBuffer.buffer;\n        } catch (err) {\n            throw new OperationError(`Error blurring image. (${err})`);\n        }\n    }\n\n    /**\n     * Displays the blurred image using HTML for web apps\n     *\n     * @param {ArrayBuffer} data\n     * @returns {html}\n     */\n    present(data) {\n        if (!data.byteLength) return \"\";\n        const dataArray = new Uint8Array(data);\n\n        const type = isImage(dataArray);\n        if (!type) {\n            throw new OperationError(\"Invalid file type.\");\n        }\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/BlurImage.mjs#L69-L105","documentation":"This wraps any failure during the blur step (applying the kernel) and the buffer export step. If Jimp's blur/gaussian call or image.getBuffer throws, the outer catch rethrows it as OperationError with the underlying message.","triggerScenarios":"BlurAmount out of Jimp's accepted range; Gaussian blur on an image Jimp cannot process; getBuffer failing for a mime type that cannot be re-encoded (e.g. GIF being converted to PNG).","commonSituations":"Passing a negative or very large blurAmount; feeding a GIF that triggers the PNG re-encode path with an unsupported frame layout; out-of-memory on very large images.","solutions":["Use a sane positive blurAmount within Jimp's documented range.","For GIF input, convert to PNG/JPEG first or expect the re-encode path.","Inspect err.message to distinguish blur failure from export failure."],"exampleFix":"// before\nblurAmount = -5\n// after\nblurAmount = 5","handlingStrategy":"validation","validationCode":"if (!Number.isFinite(blurAmount) || blurAmount < 0) throw new Error('blurAmount must be a non-negative number');","typeGuard":"function isValidBlurAmount(n) { return Number.isFinite(n) && n >= 0 && n <= 1000; }","tryCatchPattern":"try { await blurImage.run(input, args); }\ncatch (e) { if (/Error blurring/.test(e.message)) { /* reduce image size or blur radius */ } else throw e; }","preventionTips":["Keep blurAmount within Jimp's documented range.","Resize very large images before blurring.","For GIF input expect the PNG re-encode path."],"tags":["image","jimp","blur","runtime"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}