Applying a brand colour to a QR code and finding it no longer scans is a common problem. The cause is rarely the colour itself; it is the difference in brightness the camera measures. This article explains why colour breaks scanning and how far you can safely go.
A camera measures brightness, not hue
Decoding starts by splitting the captured image into light and dark modules. That step uses luminance, not hue, so a scanner effectively sees the code in black and white from the outset.
Once that step succeeds, error correction can recover a surprising amount of dirt and blur. If the image never separates into light and dark, nothing downstream runs. That is why a colour problem cannot be rescued by error correction.
The quickest way to check your own code is to convert the image to greyscale in any editor. If the pattern is not legible in grey, it is not legible to a scanner either.
Do not invert the polarity
QR codes are designed around dark modules on a light background. An inverted code, light modules on a dark background, falls outside that assumption.
In practice some readers do handle inverted codes, because their implementation detects polarity automatically. That is a courtesy of the implementation, not a guaranteed behaviour. A code that scans on your own phone is not proof that it scans for everyone. On printed material, which cannot be changed later, the safe choice is not to invert.
If the surrounding design has to be dark, place a light patch under the code itself and keep the modules dark on top of it. The polarity is then preserved.
How much brightness difference is needed
As a rule of thumb, a relative luminance ratio of 4:1 or better between foreground and background is comfortable under normal lighting. Below 3:1, failures start appearing in dim rooms and at oblique angles.
The point to watch is that visual boldness and luminance difference are not the same thing. Red on black looks like a strong contrast to the eye, yet the luminance difference is small, and in greyscale both collapse into dark modules. The same happens with deep blue on black and deep green on black.
Conversely, pairs such as black on yellow or navy on pale cyan keep scanning well because the light side stays genuinely light. If you are going to add colour, keep the light background close to white and colour the other side.
Combinations to avoid
- Red modules on a black background - the classic case of no luminance difference.
- Pale modules on a white background - pastel modules do not separate from white.
- Gradient modules - luminance varies by position, so no single threshold works.
- Metallic inks - brightness flips with the viewing angle, creating angles that scan and angles that do not.
- Colouring both modules and background - colouring only one side fails far less often.
Codes placed over photographs
Overlaying a code on a photograph is the most failure-prone layout, because luminance changes across the image. The fix is simple: put a plain patch underneath the code.
That patch has to extend beyond the code. The specification asks for a quiet zone of four modules around the symbol, and the patch must cover that margin as well. Making only the inside of the margin white, while the outside remains photographic, can prevent the boundary from being detected.
The patch does not have to be a square, but it must not eat into the margin. If you want rounded corners, enlarge the patch first and round the corners of the larger shape.
Measure before you commit
Rather than choosing a colour and hoping, generate the code in the candidate colours and check it. Save the result as an image, confirm the pattern is legible in greyscale, and try it in a dimly lit room.
Check your own code
Tools are available for generating a code with specific foreground and background colours, for reading the structure of a code, and for diagnosing a code that will not scan.
QR Code Generator / QR Code Analyzer / Photo QR Code Restorer
Summary
Coloured codes fail because of brightness, not hue. Work through three checks in order: keep the polarity, keep the light side genuinely light, and lay a plain patch that covers the quiet zone. Follow those and a brand colour will usually scan reliably. Related reading: print size for how the margin is measured, and why a code will not scan for wider troubleshooting.