More tools for creating QR Codes in Linux

In my previous post I showed how to install CuterCode and Qreator, two simple GUI applications for producing QR Codes, in Gentoo Linux. I have now found a couple of other GUI applications, both of which offer more features than the aforementioned two, such as allowing you to specify the amount of error correction to be incorporated into the QR Code. QR Code codewords are 8 bits long and use the Reed–Solomon error correction algorithm, with four error correction levels possible in the case of QR Codes:

Level L (Low): 7% of codewords can be restored.
Level M (Medium): 15% of codewords can be restored.
Level Q (Quartile): 25% of codewords can be restored.
Level H (High): 30% of codewords can be restored.

The higher the level of error correction, the lower the storage capacity of the QR Code.

And now to the two applications …

Portable QR-Code Generator

This is a Java application, so first make sure you have installed a Java run-time environment (or Java Development Toolkit, which will include the JRE) via Portage.

Download to your home directory the archive qrcodegen_1.14.2.zip containing the compiled Java application, not the archive qrcodegen_1.14.2_src.zip with the source code (‘quellcode’ in German), from the application’s Web site. Unzip it to the directory ~/qrcodegen_1.14.2/ then enter the directory and launch the Java application from the command line as shown below:

$ cd ~/qrcodegen_1.14.2/qrcodegen
$ java -jar QRCodeGen.jar

Alternatively you can create a Desktop Configuration file QRCodeGen.desktop containing the following (change ‘fitzcarraldo’ to your own user name, of course):

[Desktop Entry]
Categories=Graphics
Comment[en_GB]=QR Code Generator is a program that lets you generate and print QR Codes easily.
Comment=QR Code Generator is a program that lets you generate and print QR Codes easily.
Exec=java -jar /home/fitzcarraldo/qrcodegen_1.14.2/qrcodegen/QRCodeGen.jar
GenericName[en_GB]=QRCodeGen
GenericName=QRCodeGen
Icon=/home/fitzcarraldo/qrcodegen_1.14.2/qrcodegen/icon.png
MimeType=
Name[en_GB]=QRCodeGen
Name=QRCodeGen
Path=/home/fitzcarraldo/qrcodegen_1.14.2/qrcodegen/
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

and make it executable:

$ chmod +x QRCodeGen.desktop

You can choose a nice PNG icon by using Google Images to search for ‘qr code icon png’ and save the image with the file name icon.png in the same directory. Then you can launch QR code Generator by double-clicking on the Desktop Configuration file.

QtQR – QR Code Generator

Download the tarball qr-tools-1.2.tar.gz from the application’s Web site, unpack it to the directory ~/qr-tools-1.2/ and make the Python scripts executable:

$ cd ~/qr-tools-1.2/qr-tools
$ chmod +x qtqr.py
$ chmod +x qrtools.py

Make sure you have installed the package media-gfx/zbar with the python USE flag set, so that the Python zbar module is also installed:

# USE="python" emerge zbar

(You may as well add the python USE flag in the line for media-gfx/zbar in the Portage package.use file so that ZBar’s Python module is installed if you upgrade or re-install ZBar via Portage in future).

Check if the Python Imaging Library (fork) dev-python/pillow is already installed:

# emerge --search pillow

If it is not already installed, install it:

# emerge pillow

Now you can launch QtQR from the command line as follows:

$ cd ~/qr-tools-1.2/qr-tools
$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/PIL ./qtqr.py

Alternatively, you can create a Desktop Configuration file qtqr.desktop with the following contents (change ‘fitzcarraldo’ to your own user name, of course):

[Desktop Entry]
Categories=Graphics
Comment[en_GB]=QtQR is a Qt based software that lets you generate QR Codes easily, scan an image file for a QR Code and decode it or use your webcam to scan a printed one.
Comment=QtQR is a Qt based software that lets you generate QR Codes easily, scan an image file for a QR Code and decode it or use your webcam to scan a printed one.
Exec=LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/PIL /home/fitzcarraldo/qr-tools-1.2/qr-tools/qtqr.py
GenericName[en_GB]=QtQR
GenericName=QtQR
Icon=/home/fitzcarraldo/qr-tools-1.2/qr-tools/icon.png
MimeType=
Name[en_GB]=QtQR
Name=QtQR
Path=/home/fitzcarraldo/qr-tools-1.2/qr-tools/
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

and make it executable:

$ chmod +x qtqr.desktop

Then you can launch QtQR by double-clicking on the Desktop Configuration file.

The QtQR GUI has a feature for decoding a QR Code in an image file and for decoding a printed QR Code held in front of a Webcam. If I select ‘Decode’ > ‘Decode from Webcam’, QtQR launches ZBar and, although it is a bit fiddly, I can successfully decode a printed QR Code. However, I cannot get QtQR to decode a QR Code in an image file that QtQR itself created (or to decode a QR Code in a file created by any other application, for that matter), so there is a bug in QtQR. Looking at the application’s bug reports this appears to be Bug No. 811576. It’s not a big deal, though, because the zbarimg command provided by ZBar can be used to decode QR Codes (see my post Installing and using ZBar in Linux to scan bar codes with your Webcam).

$ cd ~/qr-tools-1.2/qr-tools
$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/PIL ./qtqr.py
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:127: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
  set_interactive(1)
Object::connect: No such signal org::freedesktop::UPower::DeviceAdded(QDBusObjectPath)
Object::connect: No such signal org::freedesktop::UPower::DeviceRemoved(QDBusObjectPath)
kfilemodule(32309) KSambaSharePrivate::testparmParamValue: Running testparm ("-d0", "-s", "--parameter-name", "usershare path")
Traceback (most recent call last):
  File "./qtqr.py", line 481, in decodeFile
    if qr.decode():
  File "/home/fitzcarraldo/qr-tools-1.2/qr-tools/qrtools.py", line 147, in decode
    pil = Image.open(self.filename).convert('L')
  File "/usr/lib/python2.7/site-packages/PIL/Image.py", line 2256, in open
    % (filename if filename else fp))
IOError: cannot identify image file u'/home/fitzcarraldo/qr-tools-1.2/qr-tools/test.png'

Linux Magazine has a good article on these and other QR Code tools: Generating QR Codes in Linux.

UPDATE (March 30, 2015): You can download an updated working revision (Revision 20) of the Python script qrtools.py, and an updated working revision (Revision 21) of the Python script qtqr.py, from the QtQR and QR Tools developers’ repository where they have been working on an as-yet unreleased Version 1.4 of QtQR and QR Tools:

http://bazaar.launchpad.net/~qr-tools-developers/qr-tools/trunk/files

I have briefly tested qrtools.py Revision 20 and qtqr.py Revision 21 with the other QR Tools Version 1.2 files I downloaded earlier. I simply downloaded the Revison 20 qrtools.py file and the Revision 21 qtqr.py file and overwrote the qrtools.py and qtqr.py files I had extracted earlier from qr-tools-1.2.tar.gz into the directory /home/fitzcarraldo/qr-tools-1.2/qr-tools/ (and made them executable). With the new qrtools.py and new qtqr.py it is now possible for QtQR to decode QR Codes in image files as well as QR Codes scanned via a Webcam, so the bug I mentioned above should be fixed in the next official release of QtQR/QR Tools. So you may as well skip the official Version 1.2 and download all the files from the above-mentioned developers’ repository for the future Version 1.4.

About Fitzcarraldo
A Linux user with an interest in all things technical.

One Response to More tools for creating QR Codes in Linux

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.