gchq/CyberChef · error · OperationError

Error loading image. (${err})

Error message

Error loading image. (${err})

What it means

Thrown when Jimp.read(input) rejects while loading the image. The magic-byte check passed but Jimp's decoder could not parse the bytes (corrupt data, unsupported sub-format, or decode exception). The underlying Jimp error is interpolated into the message for diagnostics.

Source

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

        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {byteArray}
     */
    async run(input, args) {
        const [flipAxis] = args;
        if (!isImage(input)) {
            throw new OperationError("Invalid input file type.");
        }

        let image;
        try {
            image = await Jimp.read(input);
        } catch (err) {
            throw new OperationError(`Error loading image. (${err})`);
        }
        try {
            if (isWorkerEnvironment())
                self.sendStatusMessage("Flipping image...");
            switch (flipAxis) {
                case "Horizontal":
                    image.flip({
                        horizontal: true,
                        vertical: false,
                    });
                    break;
                case "Vertical":
                    image.flip({
                        horizontal: false,
                        vertical: true,
                    });
                    break;
            }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Open the input in an image viewer to confirm it is a valid, complete image.
  2. Re-export or re-save the image in a standard format (PNG/JPEG) and retry.
  3. Update the jimp dependency if the format is newly supported in a later version.
  4. Inspect the interpolated err text to identify the specific decoder failure.

Example fix

// before: feeding a truncated PNG
flip.run(truncatedBuffer, ['Horizontal']) // Jimp.read rejects
// after: provide the complete image
flip.run(completeBuffer, ['Horizontal'])
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await flip.run(input, args);
} catch (e) {
  if (e.type === 'OperationError' && /Error loading image/.test(e.message)) {
    // image header present but body unreadable; request a re-export
  } else throw e;
}

Prevention

When it happens

Trigger: A file whose header magic bytes match an image type but whose body is corrupt or truncated; a JPEG/PNG with unsupported features for the installed Jimp version; a GIF that passes isImage but fails Jimp's reader; a zero-byte or near-zero buffer that happened to match a magic prefix.

Common situations: Truncated download or clipboard copy of an image; older Jimp version lacking support for a modern format variant (e.g. progressive JPEG, animated GIF frame); file with correct header but corrupted pixel data; version skew after a Jimp major upgrade.

Related errors


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