gchq/CyberChef · error · OperationError

Unsupported file type (supported: jpg,png,pbm,bmp) or no fil

Error message

Unsupported file type (supported: jpg,png,pbm,bmp) or no file provided

What it means

Thrown by OpticalCharacterRecognition.run when isImage(input) returns false — the input is not a recognised image (jpg, png, pbm, bmp). Tesseract can only process raster images, so non-image data or unsupported formats (e.g. tiff, webp) are rejected before the worker is created.

Source

Thrown at src/core/operations/OpticalCharacterRecognition.mjs:63

                value: OEM_MODES,
                defaultIndex: 1
            }
        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {string}
     */
    async run(input, args) {
        const [showConfidence, oemChoice] = args;

        if (!isWorkerEnvironment()) throw new OperationError("This operation only works in a browser");

        const type = isImage(input);
        if (!type) {
            throw new OperationError("Unsupported file type (supported: jpg,png,pbm,bmp) or no file provided");
        }

        const assetDir = `${self.docURL}/assets/`;
        const oem = OEM_MODES.indexOf(oemChoice);

        try {
            self.sendStatusMessage("Spinning up Tesseract worker...");
            const image = `data:${type};base64,${toBase64(input)}`;
            const worker = await createWorker("eng", oem, {
                workerPath: `${assetDir}tesseract/worker.min.js`,
                langPath: `${assetDir}tesseract/lang-data`,
                corePath: `${assetDir}tesseract/tesseract-core.wasm.js`,
                logger: progress => {
                    if (isWorkerEnvironment()) {
                        self.sendStatusMessage(`Status: ${progress.status}${progress.status === "recognizing text" ? ` - ${(parseFloat(progress.progress)*100).toFixed(2)}%`: "" }`);
                    }
                }
            });

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Convert the source to PNG, JPG, PBM, or BMP before feeding it in.
  2. For PDFs, rasterise to PNG first (e.g. via a render operation or external tool).
  3. Ensure the upstream op outputs an ArrayBuffer containing the raw image bytes.
  4. Verify the buffer is non-empty and begins with the correct magic bytes.
Defensive patterns

Strategy: type-guard

Validate before calling

import { isImage } from "core/lib/FileType.mjs";
if (!isImage(input)) {
  // convert to PNG/JPG/PBM/BMP before running OCR
}

Type guard

const isOCRImage = (buf) => Boolean(isImage(buf));

Try / catch

try { await chef.bake("Optical Character Recognition", args, input); }
catch (e) { if (e.message.startsWith("Unsupported file type")) convertToPNG(); else throw e; }

Prevention

When it happens

Trigger: run(input, args) with an ArrayBuffer whose magic bytes are not a supported image type. Feeding a PDF, TIFF, WebP, text, or empty buffer, or a file with a spoofed extension, trips this.

Common situations: Dropped a PDF or TIFF (Tesseract supports them but CyberChef's sniffer gate does not); uploaded a screenshot saved as WebP; upstream operation produced a non-ArrayBuffer; empty buffer from a failed load; file renamed to .png but actually a document.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/e8f973a36c7794b7. Report an issue: GitHub.