gchq/CyberChef · error · OperationError
Error loading image. (${err})
Error message
Error loading image. (${err}) What it means
Wraps any failure of Jimp.read(input) inside ImageOpacity.run(). The signature passed isImage but Jimp could not decode the body (truncated, corrupt, unsupported codec). The original error is interpolated. OperationError surfaced as step output.
Source
Thrown at src/core/operations/ImageOpacity.mjs:57
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
async run(input, args) {
const [opacity] = 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("Changing image opacity...");
image.opacity(opacity / 100);
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 changing image opacity. (${err})`);
}
}
View on GitHub (pinned to 4290ea7539)
Solutions
- Read ${err} for Jimp's specific reason.
- Re-save the source as PNG or JPEG and retry.
- Confirm buffer length matches the declared image dimensions.
- Verify the installed jimp supports the codec.
Example fix
// before opacityOp.run(truncatedPng, [50]); // -> Error loading image. // after const buf = await reencodeToPng(truncatedPng); opacityOp.run(buf, [50]);
Defensive patterns
Strategy: try-catch
Try / catch
try {
await opacityOp.run(buf, [opacity]);
} catch (e) {
if (e instanceof OperationError && /Error loading image/.test(e.message)) {
reportCorruptImage(e.message);
} else throw e;
} Prevention
- Re-encode untrusted images to PNG first.
- Validate buffer length against the header.
- Pin a known-good jimp version.
- Surface Jimp's interpolated reason to the user.
When it happens
Trigger: isImage accepted the magic bytes but Jimp rejects the payload: truncated file, header present but body corrupt, or a codec Jimp does not ship. An ArrayBuffer shorter than the header declares is a common cause.
Common situations: Truncated copy-paste, image that browsers render but Jimp cannot, jimp version dropping a codec, valid signature around unrelated bytes.
Related errors
- Error loading image. (${err})
- Error loading image. (${err})
- Error adjusting image hue / saturation / lightness. (${err})
- Error changing image opacity. (${err})
- Error inverting image. (${err})
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/21a2a289607ce356.
Report an issue: GitHub.