Image credit: Mitia Ivanov/Unsplash
Two-dimensional (2D) barcodes, better known as QR codes, are back in vogue, with high demand for just about anything “contactless” these days.
Coinbase wasted no time in seizing the opportunity either: its awesome Superbowl 2022 TV commercial was nothing but a mysterious QR code on a pitch black background aimed to totally capture your attention. .
Even those who don’t understand How? ‘Or’ What exactly these quirky squares pretty much used them at some point.
But are there mobile or animated QR codes? And could they work?
Scan it by yourself.
This week, technologist, “cyborg hardware hacker” and YouTuber, Zack Freedman tweeted a GIF it went viral.
The GIF below contains an animated QR code with moving frames that some might recognize – a sequence from the famous film by Rick Astley I will never abandon you Musical clip.
The song’s lyrics and the clip itself have long been a popular meme used by netizens and even malicious actors hunting down hacked companies.
But, in addition to being an artistic barcode, Freedman’s GIF actually works like a QR code: scan it yourself!
Assuming your QR code scanner app is working, the GIF above will take you to the official I will never abandon you music video on YouTube.
In fact, there are tools online, like the one created by QR4 and software engineer Jeroen Steeman, allowing you to create your own animated QR codes!
Dive deeper into barcodes
The origins of barcodes date back to the 1950s when two graduate students from Drexel University (ahem, my alma mater) patented a system for easily cataloging and searching electronic product information.
What may have originally started as an inventory tracking concept, however, has evolved in complexity, available formats and even dimensions, with the advent of 2D barcodes.
Commonly known as QR (Quick Response) codes, these matrices are just one type of 2D barcode, invented in 1994 by the Japanese automobile company Denso Wave, which still holds the trademark of the term “QR Code” and even a patent on technology.
Whereas one-dimensional barcodes, like the UPCs you see on book covers and merchandise, are capable of containing simple one-line strings, such as a SKU, item number, or other set of characters up to a certain length (about 85 characters), 2D barcodes are much more versatile in their ability to hold data, the ability to hold different types of data, and various built-in checking and error correction mechanisms .
2D barcodes, as the name suggests, have multiple dimensions and can store data across the entire matrix, as opposed to a single row (dimension). And each part of the QR code matrix has a special meaning and role to play, the section containing the content is only a part of the whole matrix.
The error checking and error correction aspects of 2D barcodes are important in the sense that even if parts of the QR code are cut off or corrupted, the QR code may still continue to scan properly and retain the content stored there. Try it for yourself:
This is not the case for 1D barcodes – these work by the scanner calculating the ratio of the widths of straight bars next to each other. And as such, if you cover or destroy any part of the 1D barcode, it may not be read correctly.
But, the error correction mechanism built into QR codes allows barcode creators to get creative: to group functional content (like a URL or other data element) into a small part of the entire matrix , the other parts of the matrix essentially serving as a blank canvas for artistic imagery:
This explains why artistic barcodes, like the one pictured above, or the early panther GIF QR code can continue to scan correctly: the areas of the QR code containing functional data (URLs) are a smaller part of the matrix whole.
In the case of the panther GIF above, the pixels (and therefore the QR code areas) around the moving panther are relatively static, and this is where the content may be present, rather than the center where the animation is played.
But what happens in Freedman’s GIF seems to be a bit more complicated. Each frame of the GIF changes the QR code almost entirely, with the pixels rearranging.
For those familiar with computer vision, Twitter user and tech blogger Benny Baumann may have an answer for you:
Sampling: There are actually 3×3 pixel subdivisions for each of the large pixels. The processing only affects the pixels in the middle, so that’s where the data is.
The middle pixel is sometimes modified to accommodate dithering, so the “raw” encoded QR code changes over time.
—BenBE (@BenBE1987) April 22, 2022
For each small square in Freedman’s blockbuster (pun intended) QR code, your scanner only looks at the middle of each of those squares (which is 3×3 or 9 pixels in total). As such, it is in these pixels that the content portion of the barcode (the YouTube URL) is stored, with the rest of the pixels serving as a blank canvas, used for animation.
Those who prefer to learn more about “dithering” and the many possibilities it offers, might be interested in revisiting a two-year-old YCombinator Hacker News thread.
The discussion mentions the QR picture generator whose source code is available on GitHub.
The generator allows you to create fully functional QR codes that look as much like real images as possible and even animate them as you wish.