Apr 032011
 

qrencode

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.




qrencode

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" /]


Popular Posts:

flattr this!

  6 Responses to “QR Code in Linux”

  1. I think theres is a QR Code generator GUI its name QR CODE CREATER APPS front-end for qrencode

  2. A me lo script da':

    paride@rivendel:~$ bash barcode.sh
    barcode.sh: line 27: syntax error near unexpected token `else’
    barcode.sh: line 27: `else’

  3. paride@rivendel:~$ bash ./barcode.sh
    ./barcode.sh: line 19: [: too many arguments
    paride@rivendel:~$

    Ho dato come directory di destinazione /tmp

    Come nome file cicciolino.png e lui mi dice che fara’ il barcode nel file cicciolino.png.png

    Come testo ho inserito: nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura che la diritta via era smarrita

    Spero ti possa essere utile :-)

  4. C’è anche il sito http://qrcode.alvolo.it/ che permette di generare qrcode direttamente onLine.

  5. I’ve been searching for a good QR code generator for Linux. I found Zint, but I couldn’t learn how to compile it. I found qrencode, but I’m not a command line fan. I was looking for a Linux QR code generator WITH A GUI. After days of searching, I just found one. Go here https://launchpad.net/qr-tools/+download and download the python-qrtools_1.2_all.deb and the qtqr_1.2_all.deb. The first one is the backend and the second one is the GUI frontend. It installs like any other debian package and it “just works”. Thank you to the QR Tools team, David Green, Sooraj Sekhar, and Ramiro Algozino for making QR codes in Linux much much easier and for me, possible

    PS- If you want to thank me for digging this up, go buy yourself something on Amazon! Thank you. http://amazon.websale.tv

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>