Scanning
QR scanning on Linux
The reliable path on Linux is the command line, install zbar and run zbarimg file.png to decode an image, or zbarcam for a webcam. zxing-cpp offers a more capable modern decoder. For a no-install option, a browser-based scanner decodes screenshots client-side in Firefox or Chromium.
The CLI is the dependable path
No Linux desktop environment ships QR decoding in its shell, and GUI apps for it (GNOME's Decoder, various applets) exist but come and go with distributions. The tool that is always one package away is zbar:
sudo apt install zbar-tools # Debian/Ubuntu (Fedora, Arch: package "zbar")
zbarimg screenshot.png
# QR-Code:https://example.com
# scanned 1 barcode symbols from 1 images
zbarimg reads any common image format, prints the payload prefixed with the symbology,
and exits non-zero when nothing decodes, which makes it script-friendly. Useful flags:
--raw to drop the QR-Code: prefix, -q to silence the summary line.
For live scanning with a webcam:
zbarcam # opens the default camera, prints payloads to stdout
zbarcam --raw /dev/video2 # a specific camera, clean output
Each decoded code prints as a line to stdout the moment it is recognised, so you can pipe an all-day scanning station into a file or a script, the poor man's version of batch scanning.
zxing-cpp for the codes zbar misses
zbar is venerable and fast, but its decoder predates a lot of modern robustness work. zxing-cpp: the actively maintained C++ descendant of the ZXing project: copes better with damaged, dense or oddly lit codes. The quickest way to use it is the Python binding:
pip install zxing-cpp pillow
python3 -c "import zxingcpp, PIL.Image as I; print(zxingcpp.read_barcode(I.open('code.png')).text)"
A sensible division of labour: zbarimg first because it is instant, zxing-cpp when
zbar returns nothing. If you are wiring decoding into software rather than a shell, the
library landscape is mapped on
decoding QR codes programmatically.
The screenshot pipeline
The common desktop case (a code in an email or web page) is a two-step: screenshot
with whatever your environment provides (gnome-screenshot, spectacle, grim,
scrot), then zbarimg the file. On Wayland compositors where screenshot tooling is in
flux, remember the decoder only needs an image file; any capture route works.
The no-install option
A browser-based scanner decodes uploaded images and webcam frames client-side in Firefox or Chromium. Nothing sent to a server, no packages touched. It is the right answer on a locked-down machine, and the decoded-text-first behaviour is what you want for codes you do not trust. How in-browser decoding actually works is covered in browser scanning.
Generating, while you are here
The reverse direction is a one-liner too, curl against a keyless API:
curl -o qr.png "https://useqr.app/api/v1/qr?data=https://example.com&size=512"
The full API surface, including SVG output and decode endpoints, is on the curl guide.
FAQ
How do I scan a QR code on Linux?
Install zbar (zbar-tools on Debian/Ubuntu) and run zbarimg on a screenshot or image of the code, or zbarcam for live webcam scanning. Alternatively use a browser-based scanner, which needs no installation.
What is the zbarimg command for QR codes?
zbarimg file.png decodes any QR code in the image and prints its contents. Add --raw for just the payload and -q to suppress the summary, which makes it convenient in scripts and pipelines.
Why does zbar fail on some QR codes that phones read?
zbar's decoder is older and less tolerant of damage, dense modules and uneven lighting. zxing-cpp, via its Python binding or CLI, decodes many of the codes zbar misses and is the standard second attempt.
Can I scan QR codes on a Linux server without a GUI?
Yes: that is zbarimg's natural habitat. It reads image files headlessly and exits non-zero when nothing decodes, so it slots into shell scripts, cron jobs and CI pipelines directly.
Try it: free, no signup
Related
- How to scan a QR code on a computer, No desktop OS ships a real QR scanner. Decode codes on Windows, macOS or Linux with a browser-based scanner: upload a screenshot or use the webcam.
- How QR scanning works in a browser, getUserMedia plus a decoder: the native BarcodeDetector API or a wasm library. How web QR scanners work, and how to tell if yours uploads your camera.
- Decode a QR code programmatically, Read QR codes from images in code: POST bytes or a URL to the keyless decode API, or decode locally with zxing-cpp, zbar or pyzbar. Snippets included.
- How to scan a QR code on any device, On iPhone and Android, open the camera app and point it at the code: a banner appears with the destination. No separate app is needed on any current…