Tuesday, November 11, 2025

Textual content case modifications the dimensions of QR codes


Let’s make a QR code out of a sentence two methods: combined case and higher case. We’ll use Python with the qrcode library.

>>> import qrcode
>>> s = "The fast brown fox jumps over the lazy canine."
>>> qrcode.make(s).save("combined.png")
>>> qrcode.make(s.higher()).save("higher.png")

Listed below are the combined case and higher case QR codes.

The QR code creation algorithm interprets the combined case sentence as binary knowledge nevertheless it interprets the higher case sentence as alphanumeric knowledge.

Alphanumeric knowledge, within the context of QR codes, comes from the next alphabet of 45 characters:

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:

Since 45² = 2025 < 2048 = 211 two alphanumeric characters could be encoded in 11 bits. If textual content comprises a single character exterior this alphabet, similar to a decrease case letter, then the textual content is encoded as ISO/IEC 8859-1 utilizing 8 bits per character.

Switching from mixed-case textual content to higher case textual content reduces the bits per character from 8 to five.5, and so we must always anticipate the ensuing QR code to require about 30% fewer pixels. Within the instance above we go from a 33 × 33 grid all the way down to a 29 × 29 grid, from 1089 pixels to 841.

Software to Bitcoin addressess

Bech32 encoding makes use of an alphabet of 32 characters whereas Base58 encoding makes use of an alphabet of 58 characters, and so the previous wants about 17% extra characters to signify the identical knowledge. However Bech32 makes use of a monocase alphabet, and base 58 doesn’t, and so Bech32 encoding requires fewer QR code pixels to signify the identical knowledge as Base58 encoding.

(Bech32 encoding makes use of a decrease case alphabet, however the letters are transformed to higher case earlier than creating QR codes.)

Associated posts

Related Articles

Latest Articles