{"record":{"id":"3196d002f02608a4","repo":"gchq/CyberChef","slug":"error-loading-image-err-3196d0","errorCode":null,"errorMessage":"Error loading image. (${err})","messagePattern":"Error loading image\\. \\((.+?)\\)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ViewBitPlane.mjs","lineNumber":60,"sourceCode":"            },\n        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {ArrayBuffer}\n     */\n    async run(input, args) {\n        if (!isImage(input))\n            throw new OperationError(\"Please enter a valid image file.\");\n\n        const [colour, bit] = args;\n        let parsedImage;\n        try {\n            parsedImage = await Jimp.read(input);\n        } catch (err) {\n            throw new OperationError(`Error loading image. (${err})`);\n        }\n\n        const width = parsedImage.bitmap.width,\n            height = parsedImage.bitmap.height,\n            colourIndex = COLOUR_OPTIONS.indexOf(colour),\n            bitIndex = 7 - bit;\n\n        if (bit < 0 || bit > 7) {\n            throw new OperationError(\n                \"Error: Bit argument must be between 0 and 7\",\n            );\n        }\n\n        let pixel, bin, newPixelValue;\n\n        parsedImage.scan(0, 0, width, height, function (x, y, idx) {\n            pixel = this.bitmap.data[idx + colourIndex];\n            bin = Utils.bin(pixel);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ViewBitPlane.mjs#L42-L78","documentation":"Thrown by 'View Bit Plane' when Jimp.read(input) rejects. isImage already passed (magic bytes looked like an image) but Jimp could not fully decode the buffer - typically a corrupt, truncated, or unsupported-subtype image.","triggerScenarios":"An image that has valid magic bytes but is otherwise malformed, a truncated file (download/copy cut short), an unsupported codec variant, or zero-byte image data. The underlying Jimp error is appended to the message.","commonSituations":"Partial downloads, images with valid headers but corrupt pixel data, or formats Jimp's bundled version does not decode.","solutions":["Re-acquire the source image to rule out truncation/corruption.","Open the file in an image viewer to confirm it is valid; re-save/export as PNG.","Read the appended Jimp error for the specific decode failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { parsedImage = await Jimp.read(input); }\ncatch (err) { throw new Error(`Image decode failed: ${err.message}`); }","preventionTips":["Validate image integrity in a viewer before processing.","Re-export from an image editor to normalise the format."],"tags":["image","jimp","runtime","decode-failure"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}