gchq/CyberChef · error · OperationError

Error loading image. (${err})

Error message

Error loading image. (${err})

What it means

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.

Source

Thrown at src/core/operations/RotateImage.mjs:57

    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {byteArray}
     */
    async run(input, args) {
        const [degrees] = args;

        if (!isImage(input)) {
            throw new OperationError("Invalid file type.");
        }

        let image;
        try {
            image = await Jimp.read(input);
        } catch (err) {
            throw new OperationError(`Error loading image. (${err})`);
        }
        try {
            if (isWorkerEnvironment())
                self.sendStatusMessage("Rotating image...");
            image.rotate(degrees);

            let imageBuffer;
            if (image.mime === "image/gif") {
                imageBuffer = await image.getBuffer(JimpMime.png);
            } else {
                imageBuffer = await image.getBuffer(image.mime);
            }
            return imageBuffer.buffer;
        } catch (err) {
            throw new OperationError(`Error rotating image. (${err})`);
        }
    }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Inspect the embedded 'err' from Jimp for the precise decode failure.
  2. Re-acquire or repair the source image; verify it opens in an image viewer.
  3. Pre-convert unsupported formats (SVG, HEIC) to PNG/JPEG before Rotate Image.
Defensive patterns

Strategy: try-catch

Validate before calling

import { isImage } from "src/core/lib/FileType.mjs";
// isImage() catches the common case, but Jimp may still reject the body.
if (!isImage(new Uint8Array(input))) throw new Error("Not an image header");

Try / catch

try {
  image = await Jimp.read(input);
} catch (err) {
  throw new OperationError(`Error loading image. (${err})`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/998a9895393a44e5. Report an issue: GitHub.