Recently I undertook a task to develop a QR Code generator. I was surprised to find how difficult it was to find complete information on the QR Code specification.
Most of what I found only explained part of the puzzle. So my new endeavor is to completely explain the spec. I want a skilled developer to be able to create a QR Code generator just by reading these tutorials. So I’ll spend the next few weeks covering everything there is to know about QR Code generation.
This week I’ll cover basic information, what a QR Code is, and a glossary of terms. QR stands for Quick Response, and it refers to a kind of two-dimensional “bar code” created by the Japanese company Denso-Wave. They are used commonly in Japan, and are gaining popularity in the United States. They are generally meant to be scanned by mobile devices, using an application that makes use of the devices camera to scan the code. The data stored in a QR Code can be used to direct users to a specific URL, provide contact information via vCard, or even cause the device to compose a text-message or email.
Visually, QR Codes are square grids filled with black and white squares (see above.) Three of the corners have distinctive concentric squares, called Finder Patterns. The little squares that make up the symbol are called modules. Each module represents one bit of data, and is either white or black, meaning 0 or 1, respectively. Technically speaking it’s possible to use other colors so long as there is sufficient contrast, though the “official” method is to use black and white. And at least coming very close to that will give you the best chance of high compatibility with QR scanners. Most of the modules are used for data and error correction, but some are “reserved” for Finder Patterns, Timing Patterns, Version Information, Format Information, and Alignment Patterns. See Part 2 for details.
There are 40 QR Code “Versions,” which basically refers to the size. Version 1 is 21 modules wide by 21 modules tall, and each successive Version increases this by 4 modules in each direction, all the way up to Version 40, which is 177×177 modules. Each version also must be surrounded by blank white space equal in thickness to 4 modules. There’s no requirement on the dimensions of the modules however, they can be a fraction of a millimeter, or several feet square. Of course, readers will have a difficult time with very tiny symbols, and will need to be quite far away from especially large ones to capture them.
Another important option is Error Correction. Each of the 40 Versions support 4 types of Error Correction – L, M, Q, and H. L supports roughly 7% of data to be restored, M (the default) supports restoration of roughly 15% of the data, Q supports about 25%, and H, 30%. Higher EC modes allow more of the data to be recovered in case the symbol is damaged or obscured, but require more modules to be used for Error Correction, which leaves fewer to be used for data.
Next week I’ll get to the heart of it and start in with the charts and tables and diagrams and illustrations and examples. In the mean time, if you want to purchase the ISO specification, you can find it at ISO.org website.