gchq/CyberChef · error · OperationError

Invalid file type.

Error message

Invalid file type.

What it means

Thrown at the top of ImageOpacity.run() because isImage(input) returned falsy before Jimp is invoked. Identical mechanism to the other image ops: the buffer's leading bytes are not a recognized image signature. OperationError, so it becomes the step output.

Source

Thrown at src/core/operations/ImageOpacity.mjs:50

            {
                name: "Opacity (%)",
                type: "number",
                value: 100,
                min: 0,
                max: 100,
            },
        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {byteArray}
     */
    async run(input, args) {
        const [opacity] = args;
        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 (isWorkerEnvironment())
                self.sendStatusMessage("Changing image opacity...");
            image.opacity(opacity / 100);

            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

  1. Confirm the input is an image with 'Detect File Type'.
  2. Ensure the prior recipe step outputs an image ArrayBuffer.
  3. Match the op input type to the real data format.
  4. Convert the source to PNG/JPEG upstream if the format is unsupported.

Example fix

// before
opacityOp.run(new TextEncoder().encode('nope').buffer, [50]); // throws
// after
import { isImage } from "src/core/lib/FileType.mjs";
if (isImage(pngBuffer) === false) throw new Error('feed an image');
opacityOp.run(pngBuffer, [50]);
Defensive patterns

Strategy: validation

Validate before calling

import { isImage } from "src/core/lib/FileType.mjs";
const buf8 = input instanceof Uint8Array ? input : new Uint8Array(input);
if (isImage(buf8) === false) {
  throw new Error('Input is not a recognized image; cannot run opacity op.');
}

Type guard

import { isImage } from "src/core/lib/FileType.mjs";
function isImageBuffer(buf) {
  const u8 = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
  return typeof isImage(u8) === 'string';
}

Prevention

When it happens

Trigger: run(input, args) receives an ArrayBuffer that is text, hex, a non-image binary, or an image format not in the signature DB. Also when the upstream step did not output an image ArrayBuffer.

Common situations: Pasting non-image data, wrong input-format selector, or chaining after an op whose output is not an image. Modern formats (AVIF/HEIC) not detected by isImage also trigger it.

Related errors


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