encoding and decoding qr-code

Category: SW linux tools

Posted at 2021-03-31.



use linux tools qrencode and zbar-tools for qr-code handling




Most linux distributions contain these tools. They can be installed using:

sudo apt-get install qrencode
sudo apt-get install zbar-tools

Erzeugen von QR-Code:

qrencode [OPTION]... [STRING]

als always

qrencode --help

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

Example of URL

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.

Example of email

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:info@bit-field.de"

and to enter a subject line right away:

qrencode -s 6 -o qr-email-bit-field-en.png "mailto:info@bit-field.de?subject=just tried the qr code from the blog"

Scanning QR-Codes:

To read the codes from images you can use zbarimg, e.g. with the file created above:

zbarimg qr-www-bit-field.png

we get:

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.


Send us your Comment

... because software matters