50 releases (11 stable)
|new 2.1.2||Aug 12, 2018|
|2.0.2||Jul 28, 2018|
|1.0.4||May 2, 2018|
|1.0.2||Mar 5, 2018|
|0.2.2||Mar 21, 2016|
#24 in Compression
682 downloads per month
Oxipng is a multithreaded lossless PNG compression optimizer. It can be used via a command-line interface or as a library in other Rust programs.
Oxipng can be downloaded from the Releases link on the GitHub page.
Oxipng can also be installed from Cargo, via the following command:
cargo install oxipng
Alternatively, oxipng can be built from source using the latest stable or nightly Rust:
git clone https://github.com/shssoichiro/oxipng.git cd oxipng cargo build --release cp target/release/oxipng /usr/local/bin
The current minimum supported Rust version is 1.27.0. Oxipng may compile on earlier versions of Rust, but there is no guarantee.
Oxipng follows Semantic Versioning.
Oxipng is a command-line utility. Basic usage looks similar to the following:
oxipng -o 4 -i 1 --strip safe *.png
The most commonly used options are as follows:
-o 6, lower is faster, higher is better compression. The default (
-o 2) is sufficiently fast on a modern CPU and provides 30-50% compression gains over an unoptimized PNG.
-o 4is 6 times slower than
-o 2but can provide 5-10% extra compression over
-o 2. Using any setting higher than
-o 4is unlikely to give any extra compression gains and is not recommended.
-i 1will enable Adam7 PNG interlacing on any images that are processed.
-i 0will remove interlacing from all processed images. Not specifying either will keep the same interlacing state as the input image. Note: Interlacing can add 25-50% to the size of an optimized image. Only use it if you believe the benefits outweight the costs for your use case.
- Strip: Used to remove metadata info from processed images. Used via
--strip [safe,all]. Can save a few kilobytes if you don't need the metadata. "Safe" removes only metadata that will never affect rendering of the image. "All" removes all metadata that is not critical to the image. You can also pass a comma-separated list of specific metadata chunks to remove.
-scan be used as a shorthand for
More advanced options can be found by running
Although originally intended to be used as an executable, oxipng can also be used as a library in
other Rust projects. To do so, simply add oxipng as a dependency in your Cargo.toml,
extern crate oxipng in your project. You should then have access to all of the library
functions documented here. The simplest
method of usage involves creating an
Options struct and
passing it, along with an input filename, into the
Oxipng began as a complete rewrite of the OptiPNG project, which was assumed to be dead as no commit had been made to it since March 2014. (OptiPNG has since released a new version, after Oxipng was first released.) The name has been changed to avoid confusion and potential legal issues.
The core goal of rewriting OptiPNG was to implement multithreading, which would be very difficult to do within the existing C codebase of OptiPNG. This also served as an opportunity to choose a more modern, safer language (Rust).
Any contributions are welcome and will be accepted via pull request on GitHub. Bug reports can be filed via GitHub issues. Please include as many details as possible. If you have the capability to submit a fix with the bug report, it is preferred that you do so via pull request, however you do not need to be a Rust developer to contribute. Other contributions (such as improving documentation or translations) are also welcome via GitHub.
Oxipng is open-source software, distributed under the MIT license.
Tested oxipng 2.1.1 (compiled on rustc 1.30.0-nightly (73c78734b 2018-08-05)) against OptiPNG version 0.7.7 on Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz with 8 logical cores
Benchmark #1: ./target/release/oxipng -P ./tests/files/rgb_16_should_be_grayscale_8.png
Time (mean ± σ): 91.0 ms ± 1.9 ms [User: 173.7 ms, System: 25.7 ms]
Range (min … max): 88.1 ms … 96.2 ms
Benchmark #2: optipng -simulate ./tests/files/rgb_16_should_be_grayscale_8.png
Time (mean ± σ): 276.1 ms ± 3.8 ms [User: 274.1 ms, System: 1.9 ms]
Range (min … max): 271.1 ms … 283.4 ms
'./target/release/oxipng -P ./tests/files/rgb_16_should_be_grayscale_8.png' ran 3.03x faster than 'optipng -simulate ./tests/files/rgb_16_should_be_grayscale_8.png' Benchmark #1: ./target/release/oxipng -o4 -P ./tests/files/rgb_16_should_be_grayscale_8.png
Time (mean ± σ): 118.4 ms ± 2.7 ms [User: 449.4 ms, System: 23.5 ms]
Range (min … max): 114.5 ms … 124.3 ms
Benchmark #2: optipng -o 4 -simulate ./tests/files/rgb_16_should_be_grayscale_8.png
Time (mean ± σ): 932.1 ms ± 8.6 ms [User: 928.2 ms, System: 3.2 ms]
Range (min … max): 923.9 ms … 952.9 ms
'./target/release/oxipng -o4 -P ./tests/files/rgb_16_should_be_grayscale_8.png' ran 7.88x faster than 'optipng -o 4 -simulate ./tests/files/rgb_16_should_be_grayscale_8.png'
- bit-vec ^0.5.0
- byteorder ^1.0.0
- cloudflare-zlib-sys ^0.1.2
- crc ^1.2.0
- itertools ^0.7.7
- miniz_oxide 0.1.2
- num_cpus ^1.0.0
- zopfli ^0.3.4
- binary clap ^2.10.0
- parallel rayon ^1.0.0
- binary wild 1.0.1