{"record":{"id":"60eed4f6c447ef5e","repo":"gchq/CyberChef","slug":"could-not-read-a-qr-code-from-the-image","errorCode":null,"errorMessage":"Could not read a QR code from the image.","messagePattern":"Could not read a QR code from the image\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"warning","filePath":"src/core/lib/QRCode.mjs","lineNumber":60,"sourceCode":"        if (image.bitmap.data[idx + 3] === 0x00) {\n            image.bitmap.data[idx + 0] = 0xff;\n            image.bitmap.data[idx + 1] = 0xff;\n            image.bitmap.data[idx + 2] = 0xff;\n        }\n        // Otherwise, make it fully opaque at its existing colour\n        image.bitmap.data[idx + 3] = 0xff;\n    });\n    image = await Jimp.read(await image.getBuffer(JimpMime.jpeg));\n\n    const qrData = jsQR(\n        new Uint8ClampedArray(image.bitmap.data),\n        image.width,\n        image.height,\n    );\n    if (qrData) {\n        return qrData.data;\n    } else {\n        throw new OperationError(\"Could not read a QR code from the image.\");\n    }\n}\n\n/**\n * Generates a QR code from the input string\n *\n * @param {string} input\n * @param {string} format\n * @param {number} moduleSize\n * @param {number} margin\n * @param {string} errorCorrection\n * @returns {ArrayBuffer}\n */\nexport function generateQrCode(\n    input,\n    format,\n    moduleSize,\n    margin,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/lib/QRCode.mjs#L42-L78","documentation":"Thrown by parseQrCode when jsQR returns null — the image was decoded and normalised but no QR code could be located or decoded in it. There is no underlying error object; it is a deterministic 'not found' result.","triggerScenarios":"Calling parseQrCode on an image with no QR code, a QR too small/blurry/skewed for jsQR, low contrast after normalisation, partial occlusion, inverted colours, or a damaged quiet zone.","commonSituations":"Photo of a QR with glare/shadow/perspective distortion; screenshot scaled below module resolution; rotated QR; QR against a noisy background; wrong image passed.","solutions":["Provide a higher-resolution, well-lit, front-on capture with a clean quiet zone.","Try normalise=false (sometimes auto-normalise hurts low-contrast codes).","Pre-process: upscale, binarise, deskew, or increase contrast before parsing."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"async function decodeQrBestEffort(input) {\n  for (const norm of [true, false]) {\n    try { return await parseQrCode(input, norm); } catch (e) { last = e; }\n  }\n  throw last;\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await parseQrCode(input, normalise);\n} catch (e) {\n  if (e instanceof OperationError && /Could not read a QR code/.test(e.message)) {\n    // try alternate preprocessing: upscale/deskew/binarise the image\n  }\n  throw e;\n}","preventionTips":["Provide a high-resolution, well-lit, front-on capture with a clean quiet zone.","Try both normalise settings before giving up.","Pre-process low-contrast or skewed images before parsing."],"tags":["qrcode","image","jsqr","not-found","operation-error"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}