gchq/CyberChef · error · OperationError

Error loading image. (${err})

Error message

Error loading image. (${err})

What it means

Thrown by 'View Bit Plane' when Jimp.read(input) rejects. isImage already passed (magic bytes looked like an image) but Jimp could not fully decode the buffer - typically a corrupt, truncated, or unsupported-subtype image.

Source

Thrown at src/core/operations/ViewBitPlane.mjs:60

            },
        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {ArrayBuffer}
     */
    async run(input, args) {
        if (!isImage(input))
            throw new OperationError("Please enter a valid image file.");

        const [colour, bit] = args;
        let parsedImage;
        try {
            parsedImage = await Jimp.read(input);
        } catch (err) {
            throw new OperationError(`Error loading image. (${err})`);
        }

        const width = parsedImage.bitmap.width,
            height = parsedImage.bitmap.height,
            colourIndex = COLOUR_OPTIONS.indexOf(colour),
            bitIndex = 7 - bit;

        if (bit < 0 || bit > 7) {
            throw new OperationError(
                "Error: Bit argument must be between 0 and 7",
            );
        }

        let pixel, bin, newPixelValue;

        parsedImage.scan(0, 0, width, height, function (x, y, idx) {
            pixel = this.bitmap.data[idx + colourIndex];
            bin = Utils.bin(pixel);

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Re-acquire the source image to rule out truncation/corruption.
  2. Open the file in an image viewer to confirm it is valid; re-save/export as PNG.
  3. Read the appended Jimp error for the specific decode failure.
Defensive patterns

Strategy: try-catch

Try / catch

try { parsedImage = await Jimp.read(input); }
catch (err) { throw new Error(`Image decode failed: ${err.message}`); }

Prevention

When it happens

Trigger: An image that has valid magic bytes but is otherwise malformed, a truncated file (download/copy cut short), an unsupported codec variant, or zero-byte image data. The underlying Jimp error is appended to the message.

Common situations: Partial downloads, images with valid headers but corrupt pixel data, or formats Jimp's bundled version does not decode.

Related errors


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