gchq/CyberChef · error · OperationError
Invalid file type.
Error message
Invalid file type.
What it means
Thrown by NormaliseImage.run when isImage(input) returns false — the input ArrayBuffer's magic bytes do not match any recognised image signature (png, jpg, gif, bmp, etc.). The operation only colour-normalises images, so non-image data is rejected before invoking Jimp.
Source
Thrown at src/core/operations/NormaliseImage.mjs:40
this.name = "Normalise Image";
this.module = "Image";
this.description = "Normalise the image colours.";
this.infoURL = "";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
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);
}View on GitHub (pinned to 4290ea7539)
Solutions
- Feed an actual image file (PNG/JPG/GIF/BMP) as an ArrayBuffer.
- Ensure the upstream operation outputs ArrayBuffer (e.g. use 'From Hex' or 'From Base64' before this op).
- Verify the file is not truncated or zero-length.
Example fix
// before: feeding a string
chef.bake("Normalise Image", [], "not an image");
// after: feed decoded image bytes
chef.bake("Normalise Image", [], imageArrayBuffer); Defensive patterns
Strategy: type-guard
Validate before calling
import { isImage } from "core/lib/FileType.mjs";
if (!isImage(input)) {
// do not call Normalise Image; provide a real image ArrayBuffer
} Type guard
const isImageBuffer = (buf) => Boolean(isImage(buf));
Try / catch
try { await chef.bake("Normalise Image", [], input); }
catch (e) { if (e.message === "Invalid file type.") provideImage(); else throw e; } Prevention
- Confirm upstream ops emit ArrayBuffer, not string/byteArray.
- Sniff the magic bytes before baking.
- Reject empty buffers upstream.
When it happens
Trigger: run(input, args) with an ArrayBuffer whose header bytes are not a known image magic number. Feeding text, a PDF, a zip, a truncated image, or an empty buffer all produce this.
Common situations: Wrong file dropped into the input; image with a missing/corrupted header; upstream operation outputs a byteArray or string rather than an ArrayBuffer; empty buffer from a failed fetch; file with the wrong extension but actually a different format.
Related errors
- Invalid file type.
- Invalid file type.
- Invalid file type.
- Unsupported file type (supported: jpg,png,pbm,bmp) or no fil
- Invalid file type.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/61fd6d2bc4393263.
Report an issue: GitHub.