Probably you have already saw these small black and white image in some sites or while walking around your city, or if you have a smartphone probably you have already used them; they are QR Code.
From Wikipedia: A QR code (short for Quick Response) is a specific matrix barcode
(or two-dimensional code), readable by dedicated QR barcode readers and camera phones.
The code consists of black modules arranged in a square pattern on a white background.
The information encoded can be text, URL or other data.
In this article we’ll see how to create these image in Linux and some uses of these images.
This GPL software is available in Debian, Ubuntu and Fedora repository, so just use your package manager to install it,for me this means
aptitude install qrencode (ubuntu 10.10).
Once you have installed the software generate a QR Code is trivial, just write:
qrencode "http://www.linuxaria.com/" -o linuxaria.png
This will create an image that read (with the correct reader) will show the url: http://www.linuxaria.com
But qrencode can be used also with text file, try this:
cat /etc/passwd | qrencode -s 10 -o -|display
This command take as input your /etc/passwd and send the image to to the standard output where i’ve put in pipe the command display (imagemagick package) that show the result. Note also the flag -s that specify the size of dot (pixel). (default=3),
the greater is this value the bigger your image will be.
There is no GUI interface for qrencode but you can easily mix it with Zenity to create a quick interface that ask the parameters and create the image
This is an example with Zenity and qrencode, ask where to save and the name of the image, after that ask a text to be put in the qr code (thanks to ubuntuforum)
#!/bin/bash me=`whoami` outpath=`zenity --entry --title="Save path?" --text="What folder would you like to save the QR image to? Default of /home/$me/Pictures will be used if one is not entered."` button0=$? if [ $button0 -eq 0 ];then if [ -z $outpath ];then outpath=/home/`whoami`/Pictures fi pname=`zenity --entry --title="What filename?" --text="What name should be used for the output? ex: filename > filename.png"` button1=$? if [ $button1 -eq 0 ];then if [ -z $pname ];then zenity --info --title="Failure" --text="You failed to enter a filename. Exiting." else content=`zenity --entry --title="Content --" --text="What do you want your QR code to say?"` button2=$? if [ $button2 -eq 0 ];then if [ -z $content ];then zenity --info --title="Failure" --text="You failed to enter any content. Exiting." else qrencode -o "$outpath"/"$pname".png "$content" zenity --info --title="Finished --" --text="Your QR code is located at : $outpath/$pname.png" fi else zenity --info --title="Canceled" --text="QR code generation canceled - content" fi fi else zenity --info --title="Canceled" --text="QR code generation canceled - filename" fi else zenity --info --title="Canceled" --text="QR code generation canceled - file path" fi
How to use these images
Ok you now can create these nice QR Code, but what to do with them ?
Here are some ideas but i’m sure there are much more ways to use them.
1) Backup on paper.
With QR Code you could create image of important things, like your SSL Certificates keys, or Revocation Certificates or
anything not too big, transform it in a QR Code and print it.
After that put it in your security safe or in your Disaster Recovery site.
If something bad happen on your data center you’ll have something to start work with, paper takes up little space and lasts virtually forever
2) Move information to your smartphone
You have on your computer some informations and you want to move them quickly to your smartphone.. it’s easy, qrencode it !
Read the image with the QR Code reader of your smartphone and you’ll have immediately a long url, a text file or anything available on it.
If you want to do some test and don’t have a reader, you can use this online site that offer this service http://zxing.org/w/decode.jspx
Or you can use Zbar , ZBar is an open source software suite for reading bar codes from various sources, such as video streams, image files and raw intensity sensors. It supports many popular symbologies (types of bar codes) including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code. So you can use your Webcam to read the QR Code you produce, or the one that people send to you.
I hope you have liked this introduction to QR Code on Linux and for some “innovative” uses of QR Code check also this link
[amazon_enhanced asin=”B004Q9TWEG” price=”All” background_color=”332610″ link_color=”FFFFFF” text_color=”D4CE99″ /]
- In this SteamOS era where do the Linux gaming stand?
- Introduction to gnome maps
- How to manage processes with cgroup on Systemd