[ANN] Coder and Decoder of QR codes

I’m happy to discuss with you the recent work of QRCoders!! Most of them follow the suggestions of a previous discussion (2019). Now I am writing this post for more advice.
Moreover, if you also find these ideas interesting, welcome to contribute! Feel free to give your valuable suggestions to help improve this package!

New features:

  1. Introduce a new type QRCode as suggested by @c42f in the comment. The new type do help in the design of styles!

  2. Unicode plot, either by UnicodePlots.jl suggested by @carstenbauer, or by Unicode characters ['█', '▀', '▄', ' '] mentioned in issue#25
    image

  3. Add support for .jpg and .gif images

    exportqrcode(["Hello", "Julia", "!"], "hello.gif")
    

    hello

More importantly, the styling plan is drawn on the schedule! Here is a draft.

Pixel drawing

Most of the QR code styles follow the same strategy: First build the QR code, then beautify the image.

However, pixel drawing use a strategy of free-bits-calculation and error-correction-bits-modification, to similar the image by real QR-bits. This requires some decoding tricks. In this regard, I am very much grateful to Saar Ibuki for the helpful and creative advice.

Here are applications by pixel drawing:

  1. Direct drawing

    using QRCoders, TestImages, ImageTransformations
    img = testimage("cam")
    code = QRCode("Hello Julia!", version=13)
    inlen = fitimgwidth(code)
    bitimg = .!(Bool.(round.(imresize(img, (inlen, inlen)))))
    mat = imageinqrcode(code, bitimg, rate=1, fillaligment=true)
    mat |> exportbitmat("cam.png")
    
  2. Enlarging the logo in the center of an image
    logo-QRCoders
    In general, the logo should be small, otherwise it might destroy the message. However, by pixel drawing, the logo itself stores part of the message, and thus the size can be enlarged.

  3. Playing games – Tetris

    1. Convert the image to a Union{Bool, Nothing} matrix: set value 1 for the background, set 0 for the light block, and set nothing to the free area
    2. Generate a QR matrix by pixel drawing
    3. Color the QR code matrix by the image
  4. Playing videos – BadApples
    badapple_fullinside

  5. More idea, like Nest QR codes
    logo-QRCoders

Due to my limited time and energy, I am currently focusing on the implementation of this part only. When QRCoders can plot images, it can play everything in fact!

Strategies for other styles

  1. Colorful QR Code

    • For colorful pixels: use RGB values instead of black and white pixels
    • For gradient drawing: treat the black pixels as transparent ones, then draw the QR matrix onto the background
  2. Scatter plot: use scatterplot from UnicodePlots, or use the Kronecker product kron which served as a map of pixels to matrices

  3. Theme plot, like the Pac-Man
    202916368-688fa7bd-5082-46c0-898f-d64232c5f860

    1. Draw the usual QR code
    2. Randomly select some continuous black pixels to connect them as walls
    3. Randomly select some 2x2 black pixels to replace with Pacman
    4. Replace other black pixels with beans

    The package Luxor.jl, mentioned in this comment, might be a good choice for handling svg files.


BTW, the style plan proposed in issue#33 is also asked in the juliacn-meetingup-website.
If you have good ideas suitable for newcomers, welcome to the bounty issue to ask more questions. :grinning:

8 Likes