106

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?

1
  • The simplest way to scan a QR Code is to use one of those online services like e.g. qr4u.online, webqr.com
    – 4xy
    Sep 12, 2017 at 10:30

9 Answers 9

104

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.

6
  • data matrix seems way better, since it has a proper decoder and it can encode null bytes. this doesn't work: echo -en "\x00" | qrencode -t PNG -o lol.png Feb 18, 2014 at 11:34
  • I could not get the libdecodeqr examples to output anything. dmtx seems to be very limited regarding the size of the data; a regular SSH key wouldn't fit. (Also, libdmtx.org points to something very different nowadays.)
    – Raphael
    Mar 13, 2018 at 10:34
  • 3
    zbarimg --raw qr.png > output.txt to save it to a file. "QR-Code:" text is appended to the output if --raw is not enabled.
    – Saftever
    Mar 9, 2019 at 6:28
  • 1
    xbar-tools also contain a tool zbarcam with which the QR code can directly be scanned using a webcam.
    – luator
    Mar 25, 2019 at 17:31
  • 2
    Beware - the zbarimg tool will add a label QR-Code: to the output. To suppress this, use the --raw option. Dec 16, 2019 at 17:40
33

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.

0
33

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.

4
  • Sorry, I've made the comment in the wrong browser tab. :( -- If you are going to test QtQR: launchpad.net/qr-tools, there are stable and diary PPA's, you can add the daily without too much worry. Please note that if you are running Ubuntu 10.10 you need to add an extra PPA because of some dependencies not been available (zbar) There are instructions in the launchpad site. Any feddback is greatly appreciated. Cheers! Sep 16, 2011 at 18:09
  • sudo add-apt-repository ppa:qr-tools-developers/qr-tools-stable sudo apt-get update sudo apt-get install qtqr Jun 13, 2019 at 6:12
  • Here are the installation commands for QTQR sudo add-apt-repository ppa:qr-tools-developers/qr-tools-stable sudo apt-get update sudo apt-get install qtqr Jun 13, 2019 at 6:15
  • On ubuntu 20.04 the apt install works, but when I try to scan from webcam, it crashes. (respectively the webcam scan crashes)
    – jave.web
    Aug 6 at 9:14
8

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.

1
  • 1
    The "paste image" feature is just what I needed to read a QR code displayed by another program. Apr 23, 2021 at 13:36
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à!

1
  • not anymore? link doesn't work either
    – jave.web
    Aug 6 at 9:17
3

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

There's a Brainstorm request for a QR reader here: http://brainstorm.ubuntu.com/item/15111/ Included in the comments are links to Tbarcode and Decodecamera which you might want to check out. I'd link directly to them, but I can't post more than one link yet.

3
  • I've just tried DecodeCamera. But it doesn't work. The python script meet an error.
    – Benjamin
    Jan 23, 2011 at 11:13
  • If you post the error you might be able to get help with it. The way I deal with QR codes is to just point my phone at my screen and use the app on my phone.
    – Tanath
    Jan 24, 2011 at 5:32
  • brainstorm.ubuntu.com has been shut down and it no longer exists.
    – Flimm
    Jun 10 at 11:49
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
0
1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.