#bindings #ffi #image #library #multimedia

sys zbars

High-level rust bindings zo the zbar library

3 unstable releases

Uses old Rust 2015

0.2.0 May 8, 2018
0.1.1 May 7, 2018
0.1.0 May 7, 2018

#97 in #multimedia

Download history 2/week @ 2022-03-01 1/week @ 2022-03-08 12/week @ 2022-03-15 10/week @ 2022-03-22 1/week @ 2022-03-29 4/week @ 2022-04-12 2/week @ 2022-04-19 32/week @ 2022-04-26 33/week @ 2022-05-03 49/week @ 2022-05-10 12/week @ 2022-05-17 17/week @ 2022-05-24 27/week @ 2022-05-31 8/week @ 2022-06-07 2/week @ 2022-06-14

56 downloads per month


929 lines


Renamed from zbar-rs

crates.io version build status downloads docs.rs docs

High-level rust bindings zo the zbar library

Just started implementing a high-level rust binding to zbar barcode scanner library.
Some things already work, but there is still a lot to do. So don't expect this to work without flaws. And expect things to break!

Building and Running

You need zbar native library in order to build zbars.


On Linux you can simply install zbar development package. The build script uses pkg-config to probe for zbar native library.


# apt install libzbar-dev

Arch Linux

# pacman -S zbar

Feature zbar_fork_if_available is enabled by default and builds the crate against zbar 0.2 which is a more recent fork (https://github.com/procxx/zbar) if found by pkg-config.

Nothing special to consider when running your binary on Linux.


Building on Windows is a little bit uncomfortable. I only tested it on x64 with MSVC toolchain.
At first you must download this ZBar Visual Studio project.
You can either build the project or just use the prebuilt binaries in the project's lib directory. Then set the following environment variables to be able to build:

ZBAR_LIB_DIR="build output directory or directory where prebuilds are stored"
ZBAR_INCLUDE_DIR="directory where zbar.h is stored (usually named include)"

In order to run you also need to compile libiconv or download libiconv.dll from somewhere else. Both libzbar64-0.dll from lib directory and libiconv.dll have to be copied to the directory where your binary is.


Scan an image for QR codes:

extern crate zbars;

use zbars::prelude::*;

pub fn main() {
    let mut image = ZBarImage::from_path("test/qrcode.png")
        .expect("unable to create image");

    let image_scanner = ImageScanner::builder()
        .with_config(ZBarSymbolType::ZBAR_QRCODE, ZBarConfig::ZBAR_CFG_ENABLE, 1)

    let symbol_set = image_scanner.scan_image(&mut image)
        .expect("error on scanning image");

        .for_each(|symbol| {
            println!("symbol decoded: {}", symbol.data());
                .for_each(|(i, point)| {
                    println!("{}. point: {:?}", i, point);


~55K SLoC