gchq/CyberChef · error · OperationError

Error normalising image. (${err})

Error message

Error normalising image. (${err})

What it means

Thrown by NormaliseImage.run when image.normalize() or image.getBuffer() throws after a successful Jimp.read. The image decoded but colour-normalisation or re-encoding failed — often due to an unsupported colour mode, an empty pixel buffer, or an encoding bug in Jimp. The original error is interpolated.

Source

Thrown at src/core/operations/NormaliseImage.mjs:61

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

        try {
            image.normalize();

            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 normalising image. (${err})`);
        }
    }

    /**
     * Displays the normalised image using HTML for web apps
     * @param {ArrayBuffer} data
     * @returns {html}
     */
    present(data) {
        if (!data.byteLength) return "";
        const dataArray = new Uint8Array(data);

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

        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Convert the source image to a standard 8-bit sRGB PNG/JPG with another tool first.
  2. Check the Jimp version matches what CyberChef expects (see package.json).
  3. Read the interpolated err to identify whether normalize() or getBuffer() failed.
  4. For animated GIFs, extract a single frame before normalising.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await chef.bake("Normalise Image", [], input);
} catch (e) {
  if (e.message.startsWith("Error normalising image.")) {
    // convert source to standard 8-bit sRGB and retry
  } else throw e;
}

Prevention

When it happens

Trigger: run(input, args) reaching the second try-block where Jimp successfully parsed the image but normalize() or getBuffer() rejects. Triggers include 1-bit or 16-bit PNGs Jimp mishandles, animated-GIF frame issues, or an internal Jimp version incompatibility.

Common situations: Jimp version mismatch after a dependency upgrade; exotic bit-depth or colour-profile image; animated GIF (the code special-cases GIF→PNG for this reason); image with an alpha channel Jimp cannot normalise; very large image exhausting memory during normalisation.

Related errors


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