#compression

bin+lib zopfli

A Rust implementation of the Zopfli compression algorithm

16 releases

Uses new Rust 2021

new 0.7.2 Jan 23, 2023
0.7.1 Sep 7, 2022
0.7.0 Aug 19, 2022
0.6.0 Mar 5, 2022
0.1.0 Mar 9, 2016

#24 in Compression

Download history 6641/week @ 2022-10-07 6267/week @ 2022-10-14 6516/week @ 2022-10-21 6150/week @ 2022-10-28 3070/week @ 2022-11-04 3205/week @ 2022-11-11 2730/week @ 2022-11-18 3413/week @ 2022-11-25 3272/week @ 2022-12-02 2634/week @ 2022-12-09 1429/week @ 2022-12-16 1304/week @ 2022-12-23 1852/week @ 2022-12-30 1656/week @ 2023-01-06 1092/week @ 2023-01-13 1334/week @ 2023-01-20

6,224 downloads per month
Used in 12 crates (7 directly)

Apache-2.0

140KB
3K 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.56. 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, that 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.

Dependencies

~365KB