{"record":{"id":"c9b98ae0d0ecaacc","repo":"gchq/CyberChef","slug":"error-loading-image-err-c9b98a","errorCode":null,"errorMessage":"Error loading image. (${err})","messagePattern":"Error loading image\\. \\((.+?)\\)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/FlipImage.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 [flipAxis] = args;\n        if (!isImage(input)) {\n            throw new OperationError(\"Invalid input 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(\"Flipping image...\");\n            switch (flipAxis) {\n                case \"Horizontal\":\n                    image.flip({\n                        horizontal: true,\n                        vertical: false,\n                    });\n                    break;\n                case \"Vertical\":\n                    image.flip({\n                        horizontal: false,\n                        vertical: true,\n                    });\n                    break;\n            }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/FlipImage.mjs#L37-L73","documentation":"Thrown when Jimp.read(input) rejects while loading the image. The magic-byte check passed but Jimp's decoder could not parse the bytes (corrupt data, unsupported sub-format, or decode exception). The underlying Jimp error is interpolated into the message for diagnostics.","triggerScenarios":"A file whose header magic bytes match an image type but whose body is corrupt or truncated; a JPEG/PNG with unsupported features for the installed Jimp version; a GIF that passes isImage but fails Jimp's reader; a zero-byte or near-zero buffer that happened to match a magic prefix.","commonSituations":"Truncated download or clipboard copy of an image; older Jimp version lacking support for a modern format variant (e.g. progressive JPEG, animated GIF frame); file with correct header but corrupted pixel data; version skew after a Jimp major upgrade.","solutions":["Open the input in an image viewer to confirm it is a valid, complete image.","Re-export or re-save the image in a standard format (PNG/JPEG) and retry.","Update the jimp dependency if the format is newly supported in a later version.","Inspect the interpolated err text to identify the specific decoder failure."],"exampleFix":"// before: feeding a truncated PNG\nflip.run(truncatedBuffer, ['Horizontal']) // Jimp.read rejects\n// after: provide the complete image\nflip.run(completeBuffer, ['Horizontal'])","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await flip.run(input, args);\n} catch (e) {\n  if (e.type === 'OperationError' && /Error loading image/.test(e.message)) {\n    // image header present but body unreadable; request a re-export\n  } else throw e;\n}","preventionTips":["Verify images open in a standard viewer before processing.","Re-export corrupt or exotic formats to PNG/JPEG first.","Keep the jimp dependency current for format support."],"tags":["image","jimp","decode","file-type","corruption"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}