gchq/CyberChef · error · OperationError
Invalid file type.
Error message
Invalid file type.
What it means
Thrown by ResizeImage when isImage() does not recognize the input as a supported image format. The check runs before Jimp.read, so non-image or unsupported-format input is rejected early.
Source
Thrown at src/core/operations/ResizeImage.mjs:91
* @returns {byteArray}
*/
async run(input, args) {
let width = args[0],
height = args[1];
const unit = args[2],
aspect = args[3],
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({View on GitHub (pinned to 4290ea7539)
Solutions
- Provide a supported raster image (PNG/JPEG/GIF/BMP).
- Convert HEIC/WebP/other to PNG or JPEG first.
- Ensure encoded input is decoded (From Base64/From Hex) before this operation.
- Verify the file is not truncated.
Example fix
// before // input: HEIC bytes (unsupported) // after // input: same image converted to PNG
Defensive patterns
Strategy: type-guard
Validate before calling
if (!isImage(input)) throw new Error('Input is not a supported image'); Type guard
const isSupportedImage = buf => Boolean(isImage(buf));
Try / catch
try { await resizeImage(input); } catch (e) { if (/Invalid file type/.test(e.message)) convertToPng(input); else throw e; } Prevention
- Convert to PNG/JPEG first.
- Decode Base64 upstream.
When it happens
Trigger: Non-image bytes; corrupted/truncated image; an unsupported format (e.g. some HEIC/WebP variants); wrong upstream decoding.
Common situations: Piping non-image output into ResizeImage; uploading an obscure format; truncated copy-paste; missing 'From Base64' step.
Related errors
- Error opening image. (${err})
- Invalid file type.
- Error containing image. (${err})
- Error covering image. (${err})
- Please enter a valid image file.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/b46bdde9ddef7dba.
Report an issue: GitHub.