gchq/CyberChef · error · OperationError

Error loading image. (${err})

Error message

Error loading image. (${err})

What it means

Wraps any failure of Jimp.read(input). The magic bytes passed isImage, but Jimp could not decode the body (truncated, corrupt, or an unsupported subtype/version). The original error string is interpolated so you can see Jimp's reason. It is an OperationError treated as expected step output.

Source

Thrown at src/core/operations/ImageHueSaturationLightness.mjs:73

    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {byteArray}
     */
    async run(input, args) {
        const [hue, saturation, lightness] = 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 (hue !== 0) {
                if (isWorkerEnvironment())
                    self.sendStatusMessage("Changing image hue...");
                image.color([
                    {
                        apply: "hue",
                        params: [hue],
                    },
                ]);
            }
            if (saturation !== 0) {
                if (isWorkerEnvironment())
                    self.sendStatusMessage("Changing image saturation...");
                image.color([
                    {
                        apply: "saturate",

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Inspect ${err}: a Jimp 'Unsupported MIME' or 'Premature end' message tells you exactly what is wrong.
  2. Re-export or re-save the source image as PNG or JPEG and retry.
  3. Verify the buffer length matches the declared image size (no truncation).
  4. Check the installed jimp version supports the input codec.

Example fix

// before
const buf = truncatedPng; // missing final IDAT chunk
hslOp.run(buf, [0,0,0]); // -> Error loading image. (Jimp decode failed)
// after
const buf = await repairOrReencodeToPng(truncatedPng);
hslOp.run(buf, [0,0,0]);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await hslOp.run(buf, [hue, sat, light]);
} catch (e) {
  if (e instanceof OperationError && /Error loading image/.test(e.message)) {
    // Jimp rejected the body: re-encode the source or report a corrupt-file error.
    reportCorruptImage(e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: isImage returned a mime (signature present) but Jimp rejects the payload: a half-downloaded image, a header with bad CRC, a GIF/PNG with an unsupported chunk, or a format Jimp's bundled codecs cannot decode (e.g. some TIFF/ICO). Reading an ArrayBuffer whose content length is shorter than the header implies also triggers it.

Common situations: Truncated copy-paste of image bytes, an image that opens in a browser but uses a codec Jimp lacks, jimp version skew (a codec was dropped), or feeding an ArrayBuffer that is a valid signature wrapped around unrelated data.

Related errors


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