{"record":{"id":"998a9895393a44e5","repo":"gchq/CyberChef","slug":"error-loading-image-err-998a98","errorCode":null,"errorMessage":"Error loading image. (${err})","messagePattern":"Error loading image\\. \\((.+?)\\)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/RotateImage.mjs","lineNumber":57,"sourceCode":"    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {byteArray}\n     */\n    async run(input, args) {\n        const [degrees] = 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            if (isWorkerEnvironment())\n                self.sendStatusMessage(\"Rotating image...\");\n            image.rotate(degrees);\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 rotating image. (${err})`);\n        }\n    }\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/RotateImage.mjs#L39-L75","documentation":"Thrown when Jimp.read(input) rejects during Rotate Image. isImage() already passed (magic bytes looked like an image), but Jimp itself could not decode the data — typically truncated, corrupted, or a format Jimp does not support.","triggerScenarios":"A file whose header passes FileType detection but whose body is truncated/corrupt; a format present in the signature table but absent from Jimp's decoders; a zero-byte or partially-downloaded image.","commonSituations":"Downloading an image over a flaky connection that truncates the body; processing SVG or HEIC which FileType may report but Jimp cannot rasterize; feeding an image after a base64/hex decode that left padding errors.","solutions":["Inspect the embedded 'err' from Jimp for the precise decode failure.","Re-acquire or repair the source image; verify it opens in an image viewer.","Pre-convert unsupported formats (SVG, HEIC) to PNG/JPEG before Rotate Image."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { isImage } from \"src/core/lib/FileType.mjs\";\n// isImage() catches the common case, but Jimp may still reject the body.\nif (!isImage(new Uint8Array(input))) throw new Error(\"Not an image header\");","typeGuard":null,"tryCatchPattern":"try {\n  image = await Jimp.read(input);\n} catch (err) {\n  throw new OperationError(`Error loading image. (${err})`);\n}","preventionTips":["Verify the image opens in a viewer before processing.","Re-download truncated files; pre-convert SVG/HEIC to PNG."],"tags":["image","jimp","decode","operation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}