LinuxCommandLibrary

zbarimg

Read barcodes and QR codes from images

TLDR

Process an image file

$ zbarimg [image_file]
copy

SYNOPSIS

zbarimg [options] ...

PARAMETERS

-h, --help
    Show help message and exit.

-V, --version
    Display version information and exit.

-q, --quiet
    Suppress informational messages; only print barcode data.

-v, --verbose
    Enable verbose debugging output for diagnostics.

-d, --display
    Display decoded images in a window (requires X11/GTK+ support).

-o , --output=
    Write modified output image (e.g., with detected barcodes highlighted) to the specified file.

-r, --raw
    Print raw decoded data (bytes) for each barcode, without interpretation.

-x, --xml
    Print results in XML format, providing structured data about each barcode.

-S [.]=, --set [.]=
    Configure the decoder for a specific symbol type. E.g., '--set qr.enabled=1' or '--set *.disable' to disable all decoders.

-P , --preset=
    Apply a named configuration preset (e.g., default, fast, dense) for decoding.

-f , --formats=
    Limit scanning to specific barcode formats, comma-separated (e.g., '--formats=EAN-13,QR-Code').

-s , --max-size=
    Set the maximum image size for processing (e.g., '640x480'). Images larger than this may be scaled down.

-s , --scale=
    Scale the image before scanning (e.g., '0.5' for half size, '2' for double size).

-t, --time
    Print decode time statistics for performance analysis.

DESCRIPTION

zbarimg is a command-line utility from the ZBar bar code reader project designed to scan and decode bar codes from image files. It supports a variety of common 1D and 2D bar code symbologies, including QR Code, Data Matrix, EAN-13, UPC-A, Code 39, Code 128, and more. Users can feed one or more image files as input, and zbarimg will attempt to locate and decode any bar codes present within them. The command offers flexibility in output format, allowing users to choose between human-readable text, raw data, or XML output. It's a valuable tool for automating barcode reading from images in scripting or batch processing scenarios, often used in conjunction with other image manipulation tools.

CAVEATS

zbarimg's performance can vary significantly based on image quality, resolution, barcode size, and background complexity.
For very large images or images with many barcodes, processing can be slow or consume significant memory.
Some barcode types or configurations might require specific --set options to be enabled for successful decoding.
The --display option requires X11/GTK+ support to be compiled into the zbarimg binary, which may not be present in all installations.

BARCODE SYMBOLOGY CONFIGURATION

Users can fine-tune which barcode types zbarimg attempts to decode using the --set and --formats options. For example, to only look for QR Codes and EAN-13, you would use '--formats=QR-Code,EAN-13'. To disable a specific decoder (e.g., Code 39), use '--set code39.disable=1'. This helps improve performance by focusing the decoder on relevant symbologies and can prevent misreads from unintended barcode types.

IMAGE PREPROCESSING FOR BETTER RESULTS

While zbarimg has internal image processing capabilities, feeding it well-prepared images can significantly improve decoding success rates, especially with challenging inputs. Cropping, deskewing, binarizing, or adjusting contrast in an external image editor (like ImageMagick or GraphicsMagick) before passing to zbarimg can be beneficial for images with poor lighting, low contrast, or complex backgrounds.

HISTORY

The ZBar bar code reader project was initiated by Jeff Brown, with the goal of providing an open-source software suite for reading bar codes from various sources, including images and video streams. zbarimg is a fundamental component of this project, offering a simple yet powerful command-line interface for batch processing image files. Its development focuses on broad barcode symbology support and efficient decoding algorithms, making it a widely adopted tool in open-source barcode solutions.

SEE ALSO

zbarcam(1), zbar(1), convert(1) (ImageMagick), identify(1) (ImageMagick)

Copied to clipboard