{"record":{"id":"59112b635937c705","repo":"gchq/CyberChef","slug":"please-enter-a-valid-image-file","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/ExtractLSB.mjs","lineNumber":73,"sourceCode":"                type: \"option\",\n                value: [\"Row\", \"Column\"],\n            },\n            {\n                name: \"Bit\",\n                type: \"number\",\n                value: 0,\n            },\n        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {byteArray}\n     */\n    async run(input, args) {\n        if (!isImage(input))\n            throw new OperationError(\"Please enter a valid image file.\");\n\n        const bit = 7 - args.pop(),\n            pixelOrder = args.pop(),\n            colours = args\n                .filter((option) => option !== \"\")\n                .map((option) => COLOUR_OPTIONS.indexOf(option)),\n            parsedImage = await Jimp.read(input),\n            width = parsedImage.bitmap.width,\n            height = parsedImage.bitmap.height,\n            rgba = parsedImage.bitmap.data;\n\n        if (bit < 0 || bit > 7) {\n            throw new OperationError(\n                \"Error: Bit argument must be between 0 and 7\",\n            );\n        }\n\n        let i,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ExtractLSB.mjs#L55-L91","documentation":"Thrown by the Extract LSB (steganography) operation when isImage(input) returns false. The operation reads pixel RGBA data using Jimp and needs a valid image (PNG, JPEG, BMP). If the input ArrayBuffer does not match a recognized image file signature, the operation cannot proceed.","triggerScenarios":"async run(input, args) where isImage(input) returns false at line 72. Input is expected to be an ArrayBuffer containing image bytes but either is not an image or is not a supported format.","commonSituations":"Feeding a non-image file (text, PDF, audio), a corrupted/truncated image, or an unsupported image format (e.g., WebP, HEIC depending on Jimp version). Also when an upstream operation outputs non-ArrayBuffer data.","solutions":["Provide a valid image file (PNG, JPEG, or BMP) as the input ArrayBuffer.","Verify the file is not truncated or corrupted by opening it in an image viewer first.","Convert unsupported formats to PNG/JPEG before feeding to this operation.","Ensure no upstream operation changes the data type away from ArrayBuffer."],"exampleFix":"// before: input = <text file ArrayBuffer> -> isImage false -> error\n\n// after: input = <PNG image ArrayBuffer>","handlingStrategy":"type-guard","validationCode":"// Verify input is an image before calling ExtractLSB\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  // Delegates to CyberChef's FileType.isImage\n  return isImage(input);\n}","tryCatchPattern":null,"preventionTips":["Always provide a valid PNG/JPEG/BMP image as input.","Verify the image opens in a viewer before processing.","Ensure upstream operations output ArrayBuffer."],"tags":["image","steganography","input-validation","lsb"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}