#zopfli #empty

no-std bin+lib zopfli

A Rust implementation of the Zopfli compression algorithm

18 releases

0.8.0 Sep 27, 2023
0.7.4 May 27, 2023
0.7.2 Jan 23, 2023
0.7.1 Sep 7, 2022
0.1.0 Mar 9, 2016

#21 in Compression

Download history 2111/week @ 2023-08-10 2143/week @ 2023-08-17 2088/week @ 2023-08-24 2044/week @ 2023-08-31 2157/week @ 2023-09-07 1781/week @ 2023-09-14 2386/week @ 2023-09-21 2716/week @ 2023-09-28 2464/week @ 2023-10-05 2296/week @ 2023-10-12 4815/week @ 2023-10-19 5031/week @ 2023-10-26 5716/week @ 2023-11-02 5992/week @ 2023-11-09 6259/week @ 2023-11-16 5226/week @ 2023-11-23

24,175 downloads per month
Used in 31 crates (9 directly)


3.5K SLoC

Zopfli in Rust logo

Zopfli in Rust

crates.io latest version docs.rs status

This is a reimplementation of the Zopfli compression tool in Rust.

Carol Nichols started the Rust implementation as an experiment in incrementally rewriting a C library in Rust, keeping the project compiling at every step. For more information about that experiment, see the slides for a talk she gave about it and the repo as it was for the experiment.

The minimum supported Rust version (MSRV) for this crate is 1.66. Bumping this version is not considered a breaking change for semantic versioning purposes. We will try to do it only when we estimate that such a bump would not cause widespread inconvenience or breakage.

How to build

To build the code, run:

$ cargo build --release

and the executable will be in target/release/zopfli.

This should work on stable or beta Rust.

You can also run make zopfli, which will run cargo build and then symlink target/release/zopfli to just zopfli in the project root; this is what the C library does and it was useful for scripting purposes during the rewrite process to keep the command and resulting artifacts the same.

Running the tests

There are some unit tests, mostly around the boundary package merge algorithm implementation in katajainen.rs, and a property-based test for compression reversibility. These tests can be run with:

$ cargo test

Golden master tests, to check that compressed files are exactly the same as the C implementation would generate, can be run using:

$ ./test/run.sh

and then checking that git reports no changes to the files in test/results.

Or you can run make test, which will run cargo test followed by ./test/run.sh; it will fail if there are any mismatches.