how do they work and how do you make your own?

QR code

Image Credit: Mitya Ivanov/Unsplash

Two-dimensional (2D) barcodes, which are more prominently recognized as QR codes, are back in fashion – these days, just about ‘contactless’ everything is in high demand.

Coinbase also wasted no time seizing this opportunity: the genius Superbowl 2022 TV ad was nothing but a mysterious QR code against a pitch-black background aimed at capturing your full attention.

Even those who may not understand how these quirky-looking squares work have pretty much used them at some point.

But is there such a thing as moving or animated QR codes? And could they work?

Scan it yourself.

This week, technologist, “cyborg hardware hacker” and YouTuber, Zack Freedman tweeted a GIF that has gone viral.

The GIF below contains an animated QR code with moving frames that some might recognize – a sequence from Rick Astley’s famous Never Gonna Give You Up music video.

Lyrics to the song and the music video itself have long been a popular meme used by netizens and even malicious actors trolling hacked companies.

But besides being an artistic barcode, Freedman’s GIF actually works like a QR code: scan it yourself!

Assuming your QR code scanner app works, the above GIF will direct you to the official Never Gonna Give You Up music video on YouTube.

This unexpected twist left many stunned, some calling it a “weird wizardryLEGEND,” and one that even complained that YouTube was beginning to “speed-limit” the video due to excessive traffic.

There are even online tools, such as QR4 and software engineer Jeroen Steeman, that allow you to create your own animated QR codes!

example animated QR codeAnimated QR code with a panther in the middle (QR4/Jeroen Steeman)

Dive deeper into barcodes

The origins of barcodes date back to the 1950s when two graduate students at Drexel University (ahem, my alma mater) patented a system for easily cataloging and retrieving electronic product information.

What originally started out as an inventory tracking concept, however, evolved in terms of 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 barcodes, invented in 1994 by the Japanese car company Denso Wave, which still trademarks the term “QR code” and even has a patent on it. owns the technology.

While one-dimensional barcodes, like the UPCs you see on book covers and merchandise, can contain simple one-liner sequences, such as a SKU, item number, or other string of characters up to a certain length (about 85 characters), 2D barcodes are much more versatile. in their capacity to hold data, the ability to hold different types of data, and various built-in error checking and correction mechanisms.

1D barcode exampleAn example of a 1D barcode (BleepingComputer)

2D barcodes, as the name implies, have multiple dimensions and can store data across the entire matrix as opposed to just a single line (dimension). And each part of the QR code matrix has a special meaning and role to play, with the content-containing part being just a part of the whole matrix.

The error checking and correction aspects of 2D barcodes are important in that even if parts of the QR code are cut or damaged, the QR code can still continue to scan correctly and preserve the content within it. Try it yourself:

This is not the case for 1D barcodes – they work because the scanner calculates the ratio between the widths of straight bars side by side. And as such, if you cover or destroy any part of the 1D barcode, it may not be scanned correctly.

But it’s the error-correction mechanism built into QR codes that allows barcode creators to be creative: to wrap functional content (such as a URL or other piece of data) into a small portion of the entire matrix, leaving other parts of the matrix essentially serve as a blank canvas for artistic images:

artistic QR codeA QR code embellished with art will still scan correctly (Wikipedia)

This explains why artistic barcodes, as shown above, or the panther QR code GIF can continue to scan correctly in the beginning: the areas of the QR code that contain the functional data (URL) make up a smaller part of the entire matrix.

In the case of the panther GIF above, the pixels (and thus areas of QR code) around the moving panther are relatively static, and this is where the content can be present, rather than in the center where the animation is playing .

But what’s going on in Freedman’s GIF seems to be a bit more complicated. Each frame of the GIF changes the QR code almost completely, with pixels rearranging themselves.

For those well versed in computer vision, Twitter user and tech blogger BenBE may have an answer for you:

Sampling: There are actually 3×3 pixel subdivisions for each of the large pixels. Processing only cares about the middle pixels, so that’s where the data is.

The center pixel is sometimes changed to fit the dither, so the basically “raw” encoded QR code changes over time.

— BenBE (@BenBE1987) Apr 22, 2022

For each square in Freedman’s blockbuster (pun) QR code, your scanner looks only at the center of each square (which is 3×3 or 9 pixels in total). As such, it is within these pixels that the content portion of the barcode (the YouTube URL) is stored, while the rest of the pixels serve as a blank canvas, which is used for animation.

Those who prefer to read more about dithering and the many possibilities it offers may be interested in a two-year-old YCombinator Hacker News thread.

photorealistic QR codesPhotorealistic QR Codes (QRPicture)

The discussion mentions the QRPicture generator, the source of which is available on GitHub.

The generator allows you to create fully functional QR codes that resemble real images as much as possible and even animate them to your liking.

This post how do they work and how do you make your own?

was original published at “”