Saturday, August 28, 2021

[arnniscc] QR code information density on a printed page

QR codes can encode up to 7089 decimal digits per code at the lowest (L) error correction level, confirmed with qrencode 4.1.1:

perl -we 'print "9"x7089' | qrencode -l L -o - > /dev/null

(note that qrencode 3.4.4 (Ubuntu 16.04) can only go up to 7065 digits.  larger than that results in an error "Failed to encode the input data: Input data too large".)

7089 digits has entropy (information content) 7089*log(10)/log(256) = 2943.6 bytes.

at the highest (H) error correction level, the maximum is 3057 digits, also confirmed with qrencode 4.1.1 .

the largest codes are called "version 40" and are 177x177 dots.  with 4 dots of white margin (quiet zone), the width and height are 177 + 2*4 = 185 .

consider printing a 3x4 array of such codes, including quiet zones around the edge, on 8.5x11 inch paper.  the required printing resolution is the greater of

(177 + 2*4)*3/8.5 = 65.3
(177 + 2*4)*4/11 = 67.3

so 67.3 dpi .

it would be interesting to test how small QR codes can be printed then reliably scanned.  probably best to test with smaller (less "version") codes.  I personally would be suspicious of reliability beyond this point (~ 70 dpi): those dots are pretty small, probably getting close to the limits imposed by paper grain.

incidentally, if one adds half-inch page margins, the printing area has exactly the same aspect ratio as the 3x4 image.  the half-inch margin is in addition to the 4 dot quiet zone around each code.  omitting the outer border of quiet zone from the image, the magic margin is 0.554 inch:

NSolve[(8.5-s*2)/(11-s*2) - (177*3+2*4)/(177*4+3*4) == 0, s]

sticking with 3x4 array of version 40, ECC level L codes, printing both front and back, the information density is 7089*log(10)/log(256)*3*4*2 = 70647.4 bytes per physical page.  but some of that might need to be sequencing.

No comments :