Posted at 2021-03-31.
Most linux distributions contain these tools. They can be installed using:
sudo apt-get install qrencode
sudo apt-get install zbar-tools
qrencode [OPTION]... [STRING]
gives help.The cover picture for this page was made with
qrencode 'encoding and decoding qr-code' -s 6 -o en-de-code-qr.png
QR code scanners on smartphones often have settings that automatically open scanned URLs or automatically carry out other activities (email, ...). To tell a scanner that it should open a URL, we prefix 'http: //'. E.g.
qrencode -s 6 -o qr-www-bit-field.png "http://www.bit-field.de"
A scan of this pic using a mobile gives:
(sorry for German text, I hope you can understand it anyhow.)
If you set automatic opening, the preview will not be displayed and the URL will open immediately without any prompt. That is certainly practical, but also dangerous. Since we as humans can usually not read a QR code, we do not know where the link takes us. Instead of www.bit-field.de there could have been a page with evil traps.
To tell the scan program that the content of the QR code is an email address, we put 'mailto:' in front of it. e.g
qrencode -s 6 -o qr-email-bit-field.png "mailto:email@example.com"
and to enter a subject line right away:
qrencode -s 6 -o qr-email-bit-field-en.png "mailto:firstname.lastname@example.org?subject=just tried the qr code from the blog"
To read the codes from images you can use zbarimg, e.g. with the file created above:
QR-Code:http://www.bit-field.de scanned 1 barcode symbols from 1 images in 0.04 seconds
With zbar-tools you can do a lot more useful things. More about that later.
... because software matters