A leading open source enterprise wiki and web application platform used by 50,000 small businesses, many Fortune 500 companies, and millions of people. Learn more.
QR Code is a two-dimensional barcode developed by Denso-Wave in Japan. It is very popular in Japan and is getting more popular in the USA. For example, bit.ly offers a QR Code for each shortened link. Many smartphones (Android, iPhone, Nokia etc) have applications to quickly navigate to a website, dial a number or add a contact, all simply by taking a photo of a QR Code. QR is the abbreviation for Quick Response, as the creator intended the code to be decoded at high speed.
Try it out. The resulting QR Code is shown to the right.
Input:
Note: You need to login first before you can generate a QR Code; if you do not have a TWiki.org account you can use "TWikiGuest" with password "guest" (both are case sensitive).
It would be very useful to have a higher application level standard on encoding so that applications can more easily be integrated. For example, you can point your smartphone to a QR Code to import a vCard, but at this time there is no real standard to do that.
ZXing (pronounced "zebra crossing") is a Java based open-source, multi-format barcode image processing library for mobile devices. They list a rough guide to standard encoding of information in barcodes.
SPARQCode provides a service to generate and scan QR Code on the fly. They defined a higher application level standard to encode URLs, phone numbers, SMS, geolocation, contact (vCard) and calendar event (vCal). Unfortunately they do not publish the encoding. Rhetoric question: Can you call an API an API when the API is not published?
On their API discussion forum I recommended this: "Make SPARQCode a leader in the field by publishing the spec of the encodings. Other orgs will pick it up quickly, thus it will become a standard. You can benefit from increased brand recognition, and you win by offering ease of use & convenience. Submit an RFC to make it an official standard! My 2c." Their response was a non-committal "we definitely see the potential value".
If not SPARQCode, maybe Google, Apple or another major smartphone provider can drive the higher level standardization effort? I'd love to see an RFC for an application level encoding for QR Code.
Now on to some technical details. The following factors make up a QR Code:
Text to encode. This can be a URL, a phone number, or any other text input.
ECC (Error Correction Capability) level. This compensates for dirt, damage or fuzziness of the barcode. Valid values are "L" (low ECC), "M", "Q", "H" (highest ECC). A high ECC level adds more redundancy at the cost of using more space.
Symbol version of QR Code, or size of matrix. The name is a bit misleading, it is not the version of the spec, rather the size of the matrix. Valid values are "1" ... "40". Some implementations can set the symbol version automatically based on text size, text type and ECC level.
Module size, e.g. the number of pixels that make a block (a bit) of the matrix barcode.
A damaged barcode can be restored based on the ECC level:
level "L" - about 7%
level "M" - about 15%
level "Q" - about 25%
level "H" - about 30%
Each symbol version holds a number of modules as depicted to the right. Version 1 holds 21 × 21 modules, version 2 holds 25 x 25, version 3 holds 29 x 29, up to version 40 with 177 x 177 modules.
The symbol version required to encode some text is a bit complicated, depending on the length of the text, the type of text and the ECC Level. Text is encoded differently depending on the content being numeric, alfanumeric, binary or Kanji. Here is an overview on the maximum number of bytes a symbol version can hold for the commonly used ECC level "M":
The module size is the number of pixels that make a block of the matrix barcode. Here is an example of URL http://twiki.org/ encoded with different module sizes, all with symbol version 2:
Module size:
1
2
3
4
5
QR Code:
The actual pixel size of the generated image depends on the symbol version and the module size. A mandatory whitespace of 4 modules is added. For example, a symbol version 2 (with 25 modules) and module size 3 results in an image of ((25 + 2x4) x 3) x ((25 + 2x4) x 3) pixels = 99x99 pixels.
The Denso Wave Incorporated website has more details on QR Code system configuration and other specifications.
I hope this introduction was helpful in understanding QR Code. I am looking forward to feedback and comments on this topic.
References:
For the geeks among us: The implementation of the QRCodePlugin was very simple thanks to a CPAN:GD::Barcode::QRcode Perl module that does all the work. It only requires a few lines of code to do the guts:
First we generate the png image using GD::Barcode::QRcode->new() and place it into a $image variable. Then we save the image as a file in the page's attachment directory using a name like _QRCodePlugin_45bfdc4c87f4084e309bb39650020da4.png. To ensure unique image names (in case there are multiple QR Codes in a page), we build a hexadecimal string that is an MD5 hash of the CR Code text, ECC version, symbol version and module size. This is done in the _makeFilename() function:
use Digest::MD5 qw(md5_hex);
my $md5 = md5_hex( $string );
Finally we create the html <img ... /> tag and return that to the browser. Interested folks can download the plugin to study the code.
I invite you to get involved with the TWiki community. As a contributor you can influence the direction of the project. Your words become part of the conversation that steers the TWiki project.
-- Peter Thoeny - 2011-02-14
Special scanners are available to decode a QR Code. There are also web based decoders where you can upload an image or specify the URL of an image, such as:
-- Peter Thoeny - 2011-02-23
Thanks for this excellent contribution to the possibilities of developing for QR codes. Its important to follow the ISO standard, yet equally valuable to provide a unique service for encoding. Do you feel that the new corporate structure of Twiki allows start ups to develop solutions collaboratively yet still maintain value to investors?
-- Ishak Kang - 2011-03-07
Thanks Ishak. TWiki.org is and remains an open source driven project. We'd love to get you involved to grow our community as a contributor and/or a TWiki consultant. As a company (Twiki Inc) we love to work with ISVs that provide value added solutions, especially now with the new Twiki OnDemand hosting solution.
-- Peter Thoeny - 2011-03-08