QArt codes, the better way to put picture in a QR code

[Russ Cox], current Googler and formerly of Bell Labs, posted an awesome guide to putting images in a QR code. Unlike this terrible attempt I wrote last August, [Russ]‘s method does much more than simply paste an image into a QR code and hope the error correction passes. This new method generates a unique URL to be encoded for each QR code. In other words, the embedded image is actually part of the QR code and not just a copy and paste attempt.

The basis of [Russ]‘ hack is the ability to change the message contained in a QR code to be made of either ASCII/UTF-8 or decimal numbers coded as binary. By appending an anchor tag (i.e. http://swtch.com/pjw/#123456789...) to the URL that will be encoded, [Russ] can change a whole bunch of pixels in a QR code to make just about any image.

With a few tricks like building new Reed-Solomon encoded blocks, [Russ] can change where in the pixels required by the QR code are placed. This allows for the full-width image of PJW’s binary likeness to be displayed in the QR code.

[Russ] put up a QArt coder that allows anyone to put a pixelated image in any QR code. [Luke Shumaker] (thanks for sending this in, [Luke]) took this tool and put the ‘ol skull ‘n wrenches inside a QR code pointing to hackaday.com. Very nice work from [Russ], and puts my work to shame. I’ll go cry in a corner now.

Comments

  1. KNfLrPn says:

    The QR code definitely looks nice, but now the URL is ugly.

  2. Gragg says:

    I was attempting something like this, but I only got so far as appending the anchor like he did to fudge the data, and picking the mask that fits best.

    He takes it to a whole new level of maths I can’t understand by hacking the reed solomon codes as well. Bravo.

  3. mungewell says:

    Now that’s a real hack!!

    The same theory could be applied to DataMatrix I guess, however the way the bits of the message are spread about the barcode is not so ‘linear’…

    Mark me very impressed,
    Simon

  4. Justin says:

    Is the one on the left Hitler?

  5. Lord Crow says:

    From a coding theory standpoint, I’ll point out that this isn’t so very different (informationally) from pasting the logo into the QR Code.

    Both of them sacrifice a modicum of robustness to achieve the graphic. The pasted-in logos do this by destroying some data, while this new approach does it by forcing the code to represent a much larger string.

    • Gragg says:

      This method, at least in theory does not degrade the integrity of the code nearly as much as the other way, which relies on error correction fixing it.

      In theory, this provides a completely valid code, although it violates the masking parts of the spec designed to make the code the most readable.

      In the context of a url, his anchor adding technique is not particularly harmful. It is just replacing otherwise unused code space with funged data.

  6. This is very, very cool.

  7. nes says:

    Now someone needs to write an Android app that tells you exactly which blocks you need to color in to get a printed QR code to point at your own web address.

    • It’s not possible for all QR code/URL combinations.

      Simple example. Let’s say you wanted to change ‘hackaday.com’ to ‘backaday.com’ You would do this by changing the ‘h’ to a ‘b’.

      ‘h’ has a binary ascii value of 01101000 and ‘b’ has a binary ascii value of 01100010. You can change the second-to-last 0 in the ‘h’ to a 1, but since you can’t change the 1s to 0s, you’re left with ‘jackaday.com’

      That’s a simplistic explanation, but you get the point. Also, i’m not even going to check jackaday to see see if it exists.

      • JackADay says:

        is pictures of someone’s adorable dog in PDX. So disappointingly cute.

      • nes says:

        No that example is too simplistic. The original hackaday QR hack worked despite a chunk of the code being obscured by a picture. Individual squares are not equal to individual bits, but the output of some forward error correction algorithm.

        I theorize it should be equally possible to fool the reader into flipping 1s to 0s as it is 0s to 1s, but there is a limit to how many bits can be flipped.

        Just getting a reader to point a server you have control of would be doing well. Once there, it doesn’t matter what the page requested actually is as you can just create a soft link to suit the hack.

  8. Hirudinea says:

    Your right, this is a much better way of putting a picture into a QR code, the previous method sucked compared to this, the guy who did the first one should kill himself. ;)

  9. galileo says:

    I guess I’m the only one that actually likes Brian’s last attempt
    (http://hackadaycom.files.wordpress.com/2011/08/hadbanner.png) better?

  10. zibri says:

    I think mine is better (and still works!)

    http://dl.dropbox.com/u/1587166/ZQR_rot_blue_op_transp3.png

  11. jarek says:

    There are possibilities to embed really complex pictures in QR codes, even grayscale using halftone technique – here is fresh paper about it:
    http://arxiv.org/abs/1211.1572

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s