{"record":{"id":"b46bdde9ddef7dba","repo":"gchq/CyberChef","slug":"invalid-file-type-b46bdd","errorCode":null,"errorMessage":"Invalid file type.","messagePattern":"Invalid file type\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ResizeImage.mjs","lineNumber":91,"sourceCode":"     * @returns {byteArray}\n     */\n    async run(input, args) {\n        let width = args[0],\n            height = args[1];\n        const unit = args[2],\n            aspect = args[3],\n            resizeAlg = args[4];\n\n        const resizeMap = {\n            \"Nearest Neighbour\": ResizeStrategy.NEAREST_NEIGHBOR,\n            Bilinear: ResizeStrategy.BILINEAR,\n            Bicubic: ResizeStrategy.BICUBIC,\n            Hermite: ResizeStrategy.HERMITE,\n            Bezier: ResizeStrategy.BEZIER,\n        };\n\n        if (!isImage(input)) {\n            throw new OperationError(\"Invalid file type.\");\n        }\n\n        let image;\n        try {\n            image = await Jimp.read(input);\n        } catch (err) {\n            throw new OperationError(`Error loading image. (${err})`);\n        }\n        try {\n            if (unit === \"Percent\") {\n                width = image.width * (width / 100);\n                height = image.height * (height / 100);\n            }\n\n            if (isWorkerEnvironment())\n                self.sendStatusMessage(\"Resizing image...\");\n            if (aspect) {\n                image.scaleToFit({","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ResizeImage.mjs#L73-L109","documentation":"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.","triggerScenarios":"Non-image bytes; corrupted/truncated image; an unsupported format (e.g. some HEIC/WebP variants); wrong upstream decoding.","commonSituations":"Piping non-image output into ResizeImage; uploading an obscure format; truncated copy-paste; missing 'From Base64' step.","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."],"exampleFix":"// before\n//   input: HEIC bytes (unsupported)\n// after\n//   input: same image converted to PNG","handlingStrategy":"type-guard","validationCode":"if (!isImage(input)) throw new Error('Input is not a supported image');","typeGuard":"const isSupportedImage = buf => Boolean(isImage(buf));","tryCatchPattern":"try { await resizeImage(input); } catch (e) { if (/Invalid file type/.test(e.message)) convertToPng(input); else throw e; }","preventionTips":["Convert to PNG/JPEG first.","Decode Base64 upstream."],"tags":["image","resize","validation","jimp"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}