comparison mupdf-source/thirdparty/zxing-cpp/wrappers/rust/README.md @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 # zxing-cpp
2
3 zxing-cpp is a Rust wrapper for the C++ library [zxing-cpp](https://github.com/zxing-cpp/zxing-cpp).
4
5 It is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.
6 It was originally ported from the Java ZXing Library but has been developed further and now includes
7 many improvements in terms of runtime and detection performance.
8
9 ## Usage
10
11 In your Cargo.toml:
12
13 ```toml
14 [dependencies]
15 # `bundled` causes cargo to compile and statically link an up to
16 # date version of the c++ core library. This is the most convenient
17 # and safe way to build the library.
18 zxing-cpp = { version = "0.4.1", features = ["bundled", "image"] }
19 ```
20
21 Simple example reading some barcodes from a jpg file:
22
23 ```rust
24 use zxingcpp::BarcodeFormat;
25
26 fn main() -> anyhow::Result<()> {
27 let image = image::open("some-image-file.jpg")?;
28
29 let read_barcodes = zxingcpp::read()
30 .formats(BarcodeFormat::QRCode | BarcodeFormat::LinearCodes)
31 .try_invert(false);
32
33 let barcodes = read_barcodes.from(&image)?;
34
35 for barcode in barcodes {
36 println!("{}: {}", barcode.format(), barcode.text());
37 }
38
39 Ok(())
40 }
41 ```
42
43 Simple example creating a barcode and writing it to a svg file:
44
45 ```rust
46 fn main() -> anyhow::Result<()> {
47 let svg = zxingcpp::create(zxingcpp::BarcodeFormat::QRCode)
48 .from_str("https://github.com/zxing-cpp/zxing-cpp")?
49 .to_svg_with(&zxingcpp::write().scale(5))?;
50 std::fs::write("zxingcpp.svg", svg)?;
51 Ok(())
52 }
53 ```
54
55 Note: This should currently be considered a pre-release. The API may change slightly to be even more
56 idiomatic rust depending on community feedback.
57
58 ## Optional Features
59
60 zxing-cpp provides features that are behind [Cargo features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section).
61 They are:
62
63 * `bundled` uses a bundled version of the [zxing-cpp](https://github.com/zxing-cpp/zxing-cpp) c++ library.
64 * [`image`](https://crates.io/crates/image) allows convenient/implicit conversion between `ImageView`/`Image` and`GreyImage`/`DynamicImage`.
65
66 ## Benchmarking
67
68 To compare the performance of this Rust wrapper project with other available barcode scanner Rust libraries,
69 I started the project [zxing-bench](https://github.com/axxel/zxing-bench). The README contains a few
70 results to get an idea.