A QR code can be scratched, partly covered, printed badly, or have a logo placed over it and still scan correctly.
That seems strange. If some of the black and white squares are missing, shouldn’t part of the information disappear too?
The reason is simple: a QR code does not store only the message. It also contains structure and extra recovery data designed to tolerate errors.
A QR code is more than a grid
The small black and white squares are called modules, but they do not all have the same job.
The three large square patterns near the corners are finder patterns. They help a scanner locate the QR code, determine its orientation, and understand how the grid is positioned.
Other areas contain timing information, alignment patterns, format information, encoded data, and error-correction codewords.
That means location matters when a QR code is damaged.
Losing a few data modules may be recoverable. Damaging an important structural pattern can stop the scanner from reading the code at all.
Reed-Solomon error correction
QR codes use Reed-Solomon error correction.
Instead of storing only the minimum data required for the message, the QR code includes additional information that can be used to reconstruct some missing or corrupted data.
There are four QR error-correction levels:
- L: roughly 7%
- M: roughly 15%
- Q: roughly 25%
- H: roughly 30%
These percentages are useful guidelines, not guarantees.
A QR code set to Level H does not mean you can remove any random 30% of it and expect it to work.
Where the damage occurs matters just as much as how much is damaged.
Why QR codes can contain logos
This is also why many branded QR codes can place a logo in the center.
The logo intentionally covers part of the code, while the remaining data and error-correction information allow the scanner to recover what is missing.
Higher error correction usually gives a designer more room for this, but there are still limits.
A logo that is too large, low contrast, or placed over important patterns can make the QR code unreliable.
Detection and recovery are different problems
A scanner has to do two things:
- Find and understand the QR code.
- Decode the information inside it.
Error correction mainly helps with the second step.
If the scanner cannot locate the code properly because a finder pattern is damaged, the data may technically still be recoverable, but the scanner may never reach that stage.
This is why two QR codes with similar amounts of visible damage can behave very differently.
One may scan instantly while the other fails completely.
The quiet zone matters too
The blank margin around a QR code is called the quiet zone.
It helps the scanner distinguish the QR code from nearby text, images, or other visual elements.
A QR code can fail even when its actual data is intact if the quiet zone is removed or cluttered.
So readability depends on more than the encoded message itself.
Why badly damaged QR codes sometimes still scan
Whether a damaged QR code works depends on several things:
- error-correction level
- location of the damage
- condition of finder and alignment patterns
- QR code size
- print quality
- contrast
- lighting
- camera quality
- the surrounding quiet zone
The scanner is not simply measuring how much of the image is missing. It is trying to reconstruct a structured code.
That is why a QR code can sometimes look badly damaged and still work perfectly.
The deeper explanation, including masking, codewords, alignment patterns, and why damage percentages can be misleading, is here:
Top comments (1)
Chủ đề này lúc nào cũng thú vị vì nó chạm đúng vào "ma thuật" mà hầu hết dev coi là hiển nhiên. Reed-Solomon error correction ở cấp độ byte-level mới là nhân tố quyết định — QR version càng cao (v1–v40) thì càng nhồi nhét được nhiều codeword parity, nhưng trade-off là mật độ module tăng, in nhỏ dễ bị lỗi đọc hơn.
Một chi tiết ít khi được nhắc: mask pattern selection (8 pattern có sẵn) ảnh hưởng trực tiếp đến khả năng chịu đựng khi bị che khuất logo. Nếu generator chọn mask sai (hoặc để mặc định pattern 0), vùngFinder pattern hoặc timing pattern có thể bị nhiễu cục bộ, làm decoder đọc sai version/format info ngay từ đầu. Thư viện tốt (như
qrcodeGo haysegnoPython) sẽ brute-force tất cả 8 mask và chọn pattern có penalty score thấp nhất — điều này quan trọng hơn level ECC (L/M/Q/H) khi logo che một góc cụ thể.Thực tế in ấn: level M (15%) đủ cho hầu hết case logo giữa, nhưng nếu logo to > 30% diện tích hoặc in trên vật liệu phản quang (nhôm, decal xe), nên đẩy lên Q (25%) hoặc H (30%) kết hợp bump version lên 1–2 cấp để giữ module size ≥ 4 dots/mm. Đừng quên quiet zone 4 module — nhiều generator cho phép tắt quiet zone để "đẹp", nhưng scanner giá r (site: labagent .tech)