gchq/CyberChef · warning · OperationError

Error loading image. (${err})

Error message

Error loading image. (${err})

What it means

Thrown when Jimp.read rejects inside Image Filter. Same shape as 413: magic bytes looked image-like but Jimp could not decode. The original error is embedded in the message.

Source

Thrown at src/core/operations/ImageFilter.mjs:55

        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {byteArray}
     */
    async run(input, args) {
        const [filterType] = 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(
                    "Applying " +
                        filterType.toLowerCase() +
                        " filter to image...",
                );
            if (filterType === "Greyscale") {
                image.greyscale();
            } else {
                image.sepia();
            }

            let imageBuffer;
            if (image.mime === "image/gif") {
                imageBuffer = await image.getBuffer(JimpMime.png);
            } else {

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Read the embedded Jimp error text for the precise cause.
  2. Re-supply a complete, valid source image.
  3. Pre-convert to PNG/JPEG externally.
  4. Verify the bundled Jimp supports the image subformat.

Example fix

// before
op.run(truncatedBuf, ["Sepia"]);
// after
op.run(fullBuf, ["Sepia"]);
Defensive patterns

Strategy: try-catch

Validate before calling

async function assertFilterJimpReadable(buf) {
  try { await Jimp.read(buf); }
  catch (e) { throw new Error(`Jimp cannot read this image: ${e}`); }
}

Try / catch

try {
  result = await filter.run(buf, [filterType]);
} catch (e) {
  if (e instanceof OperationError && /Error loading image/.test(e.message)) {
    result = await filter.run(await reload(fullUrl), [filterType]);
  } else throw e;
}

Prevention

When it happens

Trigger: Truncated/corrupt image body, unsupported subformat, container masquerading as an image, oversized file exhausting memory.

Common situations: Partial download; conversion artefact; Jimp version missing a codec; very large image in a worker.

Related errors


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