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:
-
Introduce a new type
QRCode
as suggested by @c42f in the comment. The new type do help in the design of styles! -
Unicode plot, either by UnicodePlots.jl suggested by @carstenbauer, or by Unicode characters
['█', '▀', '▄', ' ']
mentioned in issue#25
-
Add support for
.jpg
and.gif
imagesexportqrcode(["Hello", "Julia", "!"], "hello.gif")
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:
-
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")
-
Enlarging the logo in the center of an image
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. -
Playing games – Tetris
- Convert the image to a
Union{Bool, Nothing}
matrix: set value 1 for the background, set 0 for the light block, and setnothing
to the free area - Generate a QR matrix by pixel drawing
- Color the QR code matrix by the image
- Convert the image to a
-
Playing videos – BadApples
-
More idea, like Nest QR codes
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
-
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
- For colorful pixels: use
-
Scatter plot: use
scatterplot
from UnicodePlots, or use the Kronecker productkron
which served as a map of pixels to matrices -
Theme plot, like the Pac-Man
- Draw the usual QR code
- Randomly select some continuous black pixels to connect them as walls
- Randomly select some 2x2 black pixels to replace with Pacman
- 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.