gchq/CyberChef · error · OperationError

Please enter a valid image file.

Error message

Please enter a valid image file.

What it means

Thrown by RandomizeColourPalette when the input is not recognized by CyberChef's isImage() check as a supported image format (PNG/JPEG/GIF/BMP/etc.). The operation needs a decodable image to scan pixels and remap colours.

Source

Thrown at src/core/operations/RandomizeColourPalette.mjs:49

        this.outputType = "ArrayBuffer";
        this.presentType = "html";
        this.args = [
            {
                name: "Seed",
                type: "string",
                value: "",
            },
        ];
    }

    /**
     * @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 seed = args[0] || Math.random().toString().substr(2),
            parsedImage = await Jimp.read(input),
            width = parsedImage.bitmap.width,
            height = parsedImage.bitmap.height;

        let rgbString, rgbHash, rgbHex;

        parsedImage.scan(0, 0, width, height, function (x, y, idx) {
            rgbString = this.bitmap.data.slice(idx, idx + 3).join(".");
            rgbHash = runHash("md5", Utils.strToArrayBuffer(seed + rgbString));
            rgbHex = rgbHash.substr(0, 6) + "ff";
            parsedImage.setPixelColor(parseInt(rgbHex, 16), x, y);
        });

        const imageBuffer = await parsedImage.getBuffer(parsedImage.mime);

        return new Uint8Array(imageBuffer).buffer;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Confirm the input is a supported raster image (PNG/JPEG/GIF/BMP).
  2. Re-export/convert the source image to PNG or JPEG first.
  3. Verify the bytes were not truncated or Base64-mangled before reaching the operation.
  4. Check that an upstream 'From Base64' / 'From Hex' step decoded correctly.

Example fix

// before
//   input: raw text or partial PNG bytes
// after
//   input: a complete PNG file (signature 89 50 4E 47 ...)
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 randomizePalette(input); } catch (e) { if (/valid image/.test(e.message)) convertToPng(input); else throw e; }

Prevention

When it happens

Trigger: Feeding non-image bytes (text, archives, audio); a corrupted or truncated image file; an unsupported/obscure image format.

Common situations: Piping the wrong operation output into RandomizeColourPalette; copying a truncated image; using a format (e.g. HEIC, WebP variant) the isImage detector does not recognize.

Related errors


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