Apr 032011
 

qrencode Probabilmente avete già visto queste piccole immagini in bianco e nero, in alcuni siti o mentre camminate intorno alla vostra città, o se avete uno smartphone probabilmente le avete anche già usate, sono QR Code.

Da Wikipedia: Un Codice QR (in inglese QR Code) è un codice a barre bidimensionale a matrice, composto da moduli neri disposti all’interno di uno schema di forma quadrata. Viene impiegato per memorizzare informazioni generalmente destinate ad essere lette tramite un telefono cellulare o uno smartphone. In un solo crittogramma sono contenuti 7.089 caratteri numerici e 4.296 alfanumerici.

In questo articolo vedremo come creare queste immagini in Linux e alcuni usi di questi codici



qrencode

Questo software GPL è disponibile nei repository di Debian, Ubuntu e Fedora, quindi basta usare il gestore di pacchetti di distribuzione per l’installazione, per me questo significa dare aptitude install qrencode (Ubuntu 10.10).
Una volta installato il software generare un codice QR è banale, basta scrivere:

qrencode "http://www.linuxaria.com/" -o linuxaria.png

Questo creerà una immagine che letta (con il lettore corretto) mostrerà l’url: http://www.linuxaria.com

Ma qrencode può essere utilizzato anche con file di testo, provate questo:

cat /etc/passwd | qrencode -s 10 -o -|display

Questo comando prende come input il file /etc/passwd ed invia l’immagine allo standard output, dove ho messo io in pipe il comando display (pacchetto ImageMagick) che mostra il risultato. Notare inoltre l’opzione -s che specifica la dimensione del punto (pixel). (default = 3), maggiore è questo valore più grande sarà l’immagine prodotta.

Non esiste un’interfaccia grafica per qrencode ma si può facilmente integrare con Zenity per creare un’interfaccia veloce che chieda i parametri e crei l’immagine.

Questo è un esempio con Zenity e qrencode, chiederà dove salvare e il nome dell’immagine, dopo di che chiedere un testo da inserire nel codice QR (grazie a 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

Come usare queste immagini

Ok ora sapete creare questi bei QR Code, ma cosa farne ?
Ecco alcune idee, ma sono sicuro che ci sono molti altri modi per usarli.

1) Backup su carta.

Con il QR Code è possibile creare un’immagine di cose importanti, come la vostre chiavi dei certificati SSL , o certificati di revoca o
qualsiasi cosa non troppo grande, lo trasformatelo in un QR Code e stampatelo.
Dopo di che va mettetelo in una cassetta di sicurezza o nel vostro sito di disaster recovery.

Se succede qualcosa di brutto sul vostro centro dati avrete qualcosa con cui iniziare a lavorare, la carta occupa poco spazio e dura praticamente per sempre

2) Spostare le informazioni sul vostro smartphone

Avete sul vostro computer alcune informazioni e si desidera spostare rapidamente sul vostro smartphone .. facile, usate qrencode!

Leggete l’immagine con il lettore di codice QR del vostro smartphone e avrete immediatamente una url lunga, un file di testo o qualsiasi cosa si possa codificare a questo modo.

Se volete fare qualche prova e non disponete di un lettore, è possibile utilizzare un sito online che offre questo servizio http://zxing .org / w / decode.jspx

Oppure si può usare Zbar , ZBar è una suite software open source per la lettura di codici a barre da varie fonti, quali flussi video o file di immagini. Sostiene molti codici diffusi (tipi di codici a barre), compreso EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 e QR Code. Così si può usare la propria webcam per leggere il codice QR che si produce, o quelli che vi vengono spediti.

Spero che abbiate gradito questa introduzione aliQR Code su Linux e per qualche uso “innovativo” di QR Code controllate anche questo link

[amazon_enhanced asin=”B004Q9TWEG” price=”All” background_color=”332610″ link_color=”FFFFFF” text_color=”D4CE99″ /]

Popular Posts:

Flattr this!

  7 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

  6. Get real, just more package unpacking problems. i,am like a billion other linux users, sitting with packages none of us can untar, ungunzip, or bunzip, to the correct directory. That Fedora 22 Software installer,works about the best of all of them, but still would not install this .rpm, and yumex -n, yumex is worthless, it’s never opened a damn package i ever downloaded,it’s absolutely worthless,about all it ever did, was destroy my Livna, and my rawhide repos, after i updated to a newer version, that’s what it’s good for, removing any non redhat repo,and leaving the proprietary redhat repos, works great for that.. the new dnf package installer would not install it either, so, so much for that much improved CLI package manager, you call (dnf), it’s Just another CLI, there are never any Gui’s just CLI.To install any thing in Microsoft Windows, you just double click, and it’s installed,Bingo just like that,you never have
    any problems installing anything at all, but with linux this has been on going nightmare for 25 years now, and still you cannot install a damn package.And it is so mind bending to get them unpacked to the correct directory, the readme does not even tell you were to unpack it,any more, that was the first line in the readme file, years ago, was were to install it.Now you will never see mention of the proper directory to unpack it to, any were in the readme file, at all, any more,why?. Linux needs to resolve this package installing nightmare, once and for all, and get rid of all those old CLI 1980’s guy’s off the software writers committees.They went from a yumex Gui, to a dnf CLI. That’s a step forward, isn’t it?.

Leave a Reply to jaomadn Cancel reply

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=""> <s> <strike> <strong>

(required)

(required)

*