gchq/CyberChef · error · OperationError
Error loading image. (${err})
Error message
Error loading image. (${err}) What it means
Thrown by ResizeImage when Jimp.read(input) throws — i.e. the bytes passed the isImage() signature check but Jimp could not decode them. The underlying Jimp error is wrapped into the message. This indicates a file that looks like an image by magic bytes but is malformed.
Source
Thrown at src/core/operations/ResizeImage.mjs:98
resizeAlg = args[4];
const resizeMap = {
"Nearest Neighbour": ResizeStrategy.NEAREST_NEIGHBOR,
Bilinear: ResizeStrategy.BILINEAR,
Bicubic: ResizeStrategy.BICUBIC,
Hermite: ResizeStrategy.HERMITE,
Bezier: ResizeStrategy.BEZIER,
};
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 (unit === "Percent") {
width = image.width * (width / 100);
height = image.height * (height / 100);
}
if (isWorkerEnvironment())
self.sendStatusMessage("Resizing image...");
if (aspect) {
image.scaleToFit({
w: width,
h: height,
mode: resizeMap[resizeAlg],
});
} else {
image.resize({
w: width,View on GitHub (pinned to 4290ea7539)
Solutions
- Re-export/re-save the image with a standard tool (ImageMagick, Preview, Photoshop).
- Re-download to rule out truncation.
- For very large images, downscale externally first to avoid Jimp memory limits.
- Inspect the wrapped err to see which decoder stage failed.
Example fix
// before // input: PNG header + truncated body -> Jimp throws // after // input: complete, re-saved PNG that Jimp can decode
Defensive patterns
Strategy: try-catch
Validate before calling
let ok; try { await Jimp.read(input); ok = true; } catch { ok = false; } if (!ok) throw new Error('Image will fail to decode'); Type guard
async function decodableByJimp(buf){ try { await Jimp.read(buf); return true; } catch { return false; } } Try / catch
try { await resizeImage(input); } catch (e) { if (/Error loading image/.test(e.message)) reencodeImage(input); else throw e; } Prevention
- Re-encode images with standard tools before resizing.
- Watch for truncation in large files.
- Downscale huge images externally to avoid Jimp memory limits.
When it happens
Trigger: Truncated or corrupt image (valid header but incomplete pixel data); a file with a spoofed image signature; an image using a sub-format Jimp's decoder rejects; an unsupported color space or compression.
Common situations: Partially downloaded images; files renamed to .png/.jpg without real conversion; images produced by non-standard encoders; memory-limit failures inside Jimp on very large images.
Related errors
- Error containing image. (${err})
- Error covering image. (${err})
- Error loading image. (${err})
- Error loading image. (${err})
- Error opening image file. (${err})
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/68a041f55a440f8b.
Report an issue: GitHub.