gchq/CyberChef · error · OperationError
Error opening image file. (${err})
Error message
Error opening image file. (${err}) What it means
Thrown by NormaliseImage.run when Jimp.read(input) rejects. The magic-byte check (isImage) passed, but Jimp could not decode the buffer — typically because the file is truncated, has a valid header but corrupt body, or uses a sub-format Jimp does not support. The original error is interpolated into the message.
Source
Thrown at src/core/operations/NormaliseImage.mjs:47
this.presentType = "html";
this.args = [];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
async run(input, args) {
if (!isImage(input)) {
throw new OperationError("Invalid file type.");
}
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})`);
}
}
/**View on GitHub (pinned to 4290ea7539)
Solutions
- Re-obtain the source image from a known-good copy.
- Open the file in an image editor and re-export to repair structure.
- Inspect the interpolated err string for the specific Jimp failure.
- If the format is unusual (WebP/HEIC), convert to PNG/JPG first with another tool.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await chef.bake("Normalise Image", [], input);
} catch (e) {
if (e.message.startsWith("Error opening image file.")) {
// re-export the source image, then retry
} else throw e;
} Prevention
- Source images from trusted, complete files.
- Re-export exotic colour spaces to sRGB PNG/JPG first.
- Inspect the interpolated err for the Jimp-specific cause.
When it happens
Trigger: run(input, args) where isImage returns a MIME type but Jimp.read() throws asynchronously. Examples: a JPEG with a correct SOI marker but truncated scan data; a PNG missing IDAT; a GIF89a header with no image data; a WebP/HEIC that fooled the sniffer.
Common situations: Corrupt download; image truncated by a size limit; CMYK or exotic colour-space JPEG; progressive JPEG with missing segments; file that had its header patched to look like an image.
Related errors
- Error loading image. (${err})
- Error loading image. (${err})
- Error loading image. (${err})
- Error opening image. (${err})
- Error normalising image. (${err})
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/1e02e533a4639cb1.
Report an issue: GitHub.