140

I saw a QR code reading a book, but I don't have a smart phone to decode it.

So I just took a picture of it and saved the picture to my PC. I downloaded libdecoderqr0, libdecodeqr-dev, and libdecodeqr-examples for reading it. But I don't know how to use them.

What do I do next? Or is there a nicer way to read QR codes?

Benjamin
  • 10,229

9 Answers9

140

Several options:

  • Command-line QR-code decode: zbarimg

    Install the zbarimg command line application by running:

    sudo apt-get install zbar-tools
    

    Use the program zbarimg provided by the package to read your QR encoded image:

    From the command line:

    zbarimg "image-file-name.jpg"
    

    The above will display what is encoded in the image in the terminal.

  • Web-based Applications for decoding and encoding

    You can encode and decode online at online barcodereader.com and at ZXing Decoder Online.

  • Data Matrix command-line decode and encode: libdmtx

    libdmtx is a library for reading and writing Data Matrix 2D barcodes -- two-dimensional symbols that hold a dense pattern of data with built-in error correction.

    Install libdmtx-utils from the repository and try using the tools it provides:

    dmtxwrite - create Data Matrix barcodes. Simple example:

    dmtxwrite  -o image.png input.txt
    

    This will encode text contained in input.txt in current directory to an image, image.png, in the current directory.

    dmtxread - scan Data Matrix barcodes. Simple example:

    dmtxread image.png
    

    This reads the encoded image.png and writes the decoded messages to standard output.

    libdmtx Resources:

  • Command-line QR-code encoding: grencode

    If you would like to generate QR codes, you can install qrencode from the repositories.

    < input.txt qrencode -s 10 -o test.png
    

    The above will encode the information in the input.txt file in an image file called test.png.

    Or you can input text from the console with:

    qrencode -s 10 -o ubuntu.png http://www.ubuntu.com
    

    The above will generate a QR encoded image called ubuntu.png with the URL http://www.ubuntu.com encoded in it.

NotTheDr01ds
  • 22,082
Sabacon
  • 41,474
39

ZBar recognizes several kinds of bar codes, including QR codes. If I install zbar-tools

$ sudo apt-get install zbar-tools

and save that QtQR image to a file called askubuntu.png, then the zbarimg utility finds and decodes the QR code

$ zbarimg askubuntu.png 
QR-Code:http://askubuntu.com
scanned 1 barcode symbols from 1 images in 0.02 seconds

There is also a zbarcam utility, which you can use to decode QR codes spotted by your web cam.

38

QtQR

A graphical interface for creating and reading QR codes.

QtQR

QtQR can read QR codes from image files or from a webcam. It is able to recognise a number of specific types of QR code including web links, email addresses/messages, SMS messages and telephone numbers.

You could potentially scan the QR code from the book using a webcam. If you do this, ensure there is enough light and that you are holding the QR code flat and still. You will see a window with the webcam input on the screen. Wait until green dots appear then close the window and QtQR will tell you what was contained in the QR code.

As of Bionic (18.04), QtQR is available on Ubuntu by running:

sudo apt install qtqr

You can also install newer versions of QtQR by adding the PPA ppa:qr-tools-developers/qr-tools-stable and installing the package qtqr.

Flimm
  • 44,031
dv3500ea
  • 37,734
15

In 2020, you should use CoBang to scan QR code. It was written recently by me, to catch new technologies in Linux desktop.

Screenshot

How to install in Ubuntu 20.04:

sudo add-apt-repository ppa:ng-hong-quan/ppa
sudo apt update
sudo apt install cobang

It doesn't support generating QR code yet. It is not high priority because there are already some websites to do, with pretty beautiful pictures.

Flimm
  • 44,031
hongquan
  • 311
7

Google Chrome has an extension in the Chrome Web Store called QRreader.

If a QR code exists on a webpage, just right-click on it and voilĂ !

akaihola
  • 590
buxa
  • 71
  • 1
  • 1
4

I actually wanted to be able to read these QR codes myself, so I made a little app that sits up on the system tray, you click it and it highlights all of the QR codes (or bar codes) visible on the screen and tells you what they say... Also, you can click on it and copy any of the code text to the clipboard to paste into a browser etc. I'm using ZBar, and you can check it out here...

http://cnlohr.blogspot.com/2011/08/desktop-qr-code-reader-for-ubuntu.html

Anyone wanna help me turn it into a package?

2

Use a couple of existing utilities:

apt-get install scrot xclip zbar-tools

The copy QR and bar codes to clipboard with this one liner:

scrot -so /dev/stdout | zbarimg /dev/stdin | xclip

Make a shortcut for it:

mkdir -p ~/bin
tee ~/bin/qrr <<-EOF
scrot -so /dev/stdout | zbarimg /dev/stdin | xclip
EOF
chmod a+x ~/bin/qrr

If your .profile is well set up so that your local bin folder is in PATH (after next login) you can run qrr and select with your mouse a portion of your screen containing a QR code, the code is in your primary selection. Use xclip -selection clipboard to copy to clipboard.

2

There was a request for a QR reader on former Ubuntu Brainstorm:

Included in the comments are links to TBarCode/X - Barcode Software and DecodeCamera | SourceForge.net which you might want to check out.

hc_dev
  • 257
  • 2
  • 10
Tanath
  • 159
2

QTQR is not possible to install onto Ubuntu 10.04 LTS - there are broken packages. Instead of this you can use this link to get it installed.

Qreator is another QR-code creator:

repository - https://launchpad.net/qreator

homepage - http://davidplanella.org/project-showcase/qreator/

Qreator installation

Open a terminal with Ctrl+Alt+T and type these commands:

 sudo add-apt-repository ppa:qreator-hackers/qreator-stable

 sudo apt-get update

 sudo apt-get install qreator
zeroconf
  • 141