{"record":{"id":"6d1b5e9a2d6e6e83","repo":"gchq/CyberChef","slug":"please-enter-a-valid-image-file-6d1b5e","errorCode":null,"errorMessage":"Please enter a valid image file.","messagePattern":"Please enter a valid image file\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ExtractRGBA.mjs","lineNumber":52,"sourceCode":"                type: \"editableOption\",\n                value: RGBA_DELIM_OPTIONS,\n            },\n            {\n                name: \"Include Alpha\",\n                type: \"boolean\",\n                value: true,\n            },\n        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    async run(input, args) {\n        if (!isImage(input))\n            throw new OperationError(\"Please enter a valid image file.\");\n\n        const delimiter = args[0],\n            includeAlpha = args[1],\n            parsedImage = await Jimp.read(input);\n\n        let bitmap = parsedImage.bitmap.data;\n        bitmap = includeAlpha ?\n            bitmap :\n            bitmap.filter((val, idx) => idx % 4 !== 3);\n\n        return bitmap.join(delimiter);\n    }\n}\n\nexport default ExtractRGBA;\n","sourceCodeStart":34,"sourceCodeEnd":68,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ExtractRGBA.mjs#L34-L68","documentation":"Thrown by the Extract RGBA operation when isImage(input) returns false. The operation reads each pixel's RGBA values using Jimp and requires a valid image file (PNG, JPEG, BMP). Without a recognized image signature, pixel data cannot be extracted.","triggerScenarios":"async run(input, args) where isImage(input) returns false at line 51. Input must be an ArrayBuffer containing a supported image format.","commonSituations":"Feeding a non-image file, a corrupted image, or an unsupported format. Also occurs when upstream pipeline outputs non-image data or when the file is truncated.","solutions":["Provide a valid image file (PNG, JPEG, or BMP) as the input ArrayBuffer.","Verify the image opens correctly in a standard viewer.","Convert the image to a supported format if needed.","Ensure the input reaches this operation as an ArrayBuffer."],"exampleFix":"// before: input = <non-image ArrayBuffer> -> isImage false -> error\n\n// after: input = <PNG/JPEG/BMP image ArrayBuffer>","handlingStrategy":"type-guard","validationCode":"// Verify input is an image before calling ExtractRGBA\nimport { isImage } from '../lib/FileType.mjs';\nif (!isImage(input)) {\n  throw new Error('Input must be a valid image file');\n}","typeGuard":"function isValidImage(input) {\n  return isImage(input);\n}","tryCatchPattern":null,"preventionTips":["Always provide a valid PNG/JPEG/BMP image.","Verify the file is not truncated or corrupt.","Ensure the data type reaching this operation is ArrayBuffer."],"tags":["image","steganography","input-validation","rgba"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}