Creating and reading QR codes
Variety
Qrencode lets you encode any text, including URLs. You only need to use single quotes if blanks and non-standard characters appear in the text:
$ qrencode -o lpm.png http://www.linuxpromagazine.com
All modern QR code readers recognize that this is a web address and will offer to open it in the browser.
Getting an QR-encoded address automatically to enter a smartphone owner's address book is more difficult. In this case, you need to enter your address and some additional, cryptic information:
$ qrencode -o address.png 'BEGIN:VCARD VERSION:4.0 FN: N:Schuermann;Tim;;; ADR:;;Putzbrunner Str. 71;Munich;;81739; END:VCARD'
Typing this is not exactly easy, so to make life easier, you might prefer a QR code generator with a graphical user interface, such as QtQR [2].
QtQR
As the name suggests, QtQR is based on Qt. The tool relies on Python and the python-qrtools
library. You can simply install the program via the package manager on Ubuntu. For other distributions, you will find the source code and RPM and DEB packages on the project's download page [3].
The main window in QtQR is quite simple: Top left in the selection you can set what data you want to store in the QR code. For an address, choose Contact Information (PhoneBook). Depending on the type of information, QtQR displays appropriate fields (Figure 4).
As you fill out the fields, the program creates the corresponding QR code on the right. You can resize the code at top right. Pixel Size lets you set the number of pixels per square dot the QR code uses, whereas Margin Size lets you specify the size of the margin. Error Correction lets you define the correction level. Once you have set all parameters, save the code as a PNG file by clicking the Save QRCode button.
Portable QR-Code Generator
If QtQR's capabilities do not meet your needs, you can try Portable QR-Code Generator [4]. It also encodes geographical coordinates and WiFi access data, which can be useful if you want to offer guests quick access to WiFi as a hotel or coffee shop operator, for example.
Because Portable QR-Code Generator is written in Java, you must first install a Java run-time environment via the package manager. On Ubuntu, launch the Software Center and find the OpenJDK Java 7 runtime; on openSUSE 12.3, the matching package goes by the name java-1_7_0-openjdk.
The ZIP archive of the portable QR code generator is available from the project's Downloads page (to download, click on the Herunterladen link under the .zip
entry). Unzip the file on your hard drive, open a terminal window, change to the directory with the extracted files, and run the command:
$ java -jar QRCodeGen.jar
The main window appears, and a small preview window (Figure 5) shows you the QR code. In the main window, look at the top edge first. Depending on the data you want to store in the code, click on the appropriate tab; that is, to save a URL, open the URL tab, and for an address, use VCard v4.
In the selected tab, the program displays appropriate fields. For an address, you will see more tabs that group the information, but you only need to fill out the required fields. If you do not want to specify a phone number, simply ignore the Telephone tab. If the address is already in a vCard file, you can import it by clicking Read VCard.
Once you have entered the data to encode, click on Generate. The results appear in the preview window. Plain text (in the Text tab) and geographic coordinates (in the Geo URI tab) are exceptions; the preview shows the code during entry.
You can define the size of the QR codes, as well as the error correction level at the bottom left under QR Code options section. In contrast to the previously featured tools, the Portable QR code generator allows you to specify the dimensions for the final image.
If you set Requested size (pixel) to 400, the resulting QR code image is 400 screen pixels wide. However, if you want to specify the size of each dot in the code, set Mode to Module size, then in Module size (pixel) define the number of pixels to form a dot. Additionally, you can select a specific Character encoding (see the "Character Encoding" box).
Character Encoding
QR codes contain no information about the encoding method used. Therefore, programs or apps simply try to guess. If this does not work, non-standard characters like umlauts are illegible. Because current apps assume UTF-8 encoding by default, you probably want to use this setting in the Character encoding drop-down box in Portable QR-Code Generator.
To be on the safe side (e.g., because you have business partners in several countries), you should avoid non-standard characters and model your input on the ISO 8859-1 standard [5]. For more on the topic of character encoding, check out the Wikipedia entry on character encoding [6].
To the right, in the QR Code details panel, you will see some statistics that reveal, among other things, how many bytes of payload (Data byes) the QR code currently displayed contains. To check the text that the Portable QR code generator actually dumped into the QR code, look at the bottom of the window; the details are in the Data field.
You can copy the generated QR code to the clipboard (Edit | Copy QR Code to clipboard) or save a PNG format image file with File | Save As.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.