gchq/CyberChef · error · OperationError
Please enter a valid image file.
Error message
Please enter a valid image file.
What it means
Thrown by 'View Bit Plane' when isImage(input) returns false. The operation expects an ArrayBuffer containing a recognised image; if the magic bytes / content type are not a supported image format it aborts before attempting Jimp parsing.
Source
Thrown at src/core/operations/ViewBitPlane.mjs:53
type: "option",
value: COLOUR_OPTIONS,
},
{
name: "Bit",
type: "number",
value: 0,
},
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*/
async run(input, args) {
if (!isImage(input))
throw new OperationError("Please enter a valid image file.");
const [colour, bit] = args;
let parsedImage;
try {
parsedImage = await Jimp.read(input);
} catch (err) {
throw new OperationError(`Error loading image. (${err})`);
}
const width = parsedImage.bitmap.width,
height = parsedImage.bitmap.height,
colourIndex = COLOUR_OPTIONS.indexOf(colour),
bitIndex = 7 - bit;
if (bit < 0 || bit > 7) {
throw new OperationError(
"Error: Bit argument must be between 0 and 7",
);View on GitHub (pinned to 4290ea7539)
Solutions
- Provide a supported image file (PNG/JPEG/BMP/GIF etc.) as an ArrayBuffer.
- Ensure the upstream operation outputs bytes (e.g. 'From Base64' or a file input) rather than text.
- If the source is a different format, convert it to PNG first.
Defensive patterns
Strategy: type-guard
Validate before calling
if (!isImage(input)) throw new Error("Input is not a recognised image format"); Type guard
function isImage(buf) { return buf instanceof ArrayBuffer && /\x89PNG|\xff\xd8\xff|GIF8|BM/.test(String.fromCharCode(...new Uint8Array(buf.slice(0,4)))); } Prevention
- Feed image bytes via file input or From Base64, not raw text.
- Confirm the format is supported (PNG/JPEG/BMP/GIF).
When it happens
Trigger: Passing non-image bytes (text, a zip, raw bytes), an unsupported image format, or a truncated image header. Input must arrive as an ArrayBuffer whose magic bytes pass CyberChef's isImage check.
Common situations: Forgetting to switch the input type, piping a string/text operation output directly into View Bit Plane, or supplying a file format Jimp/isImage does not support (e.g. certain TIFF/HEIC variants).
Related errors
- Error opening image. (${err})
- Invalid file type.
- Please enter a valid image file.
- Invalid file type.
- Error normalising image. (${err})
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/5d3db393da22961b.
Report an issue: GitHub.