oxipng
Multithreaded lossless PNG and APNG optimizer, usable as a CLI or a Rust library.
Repository Health
Technical Analysis
oxipng is a multithreaded lossless PNG/APNG compression optimizer written in Rust. It began as a rewrite of OptiPNG focused on multithreading and has since grown its own architecture. It can be run as a fast command-line utility or embedded as a Rust library, applying filtering, recompression (including optional Zopfli), alpha optimization, and metadata stripping to shrink PNGs without any quality loss.
What You Get
- A fast
oxipngcommand-line utility with optimization levels from-o 0to-o max - A Rust library API centered on an
Optionsstruct and anoptimizefunction - Lossless filtering and recompression, with optional Zopfli for maximum compression
- Metadata stripping (safe/all) and alpha optimization for transparent images
Common Use Cases
- Optimizing PNG assets for the web to cut page weight
- Running lossless image compression as a pre-commit hook or CI step
- Embedding PNG optimization inside a larger Rust image-processing pipeline
Under The Hood
Architecture — The crate exposes a library (src/lib.rs) and a CLI binary (src/main.rs, behind the binary feature). The public flow is an Options struct passed to optimize, which reads a PNG, evaluates filter and compression strategies in parallel, and writes the smallest lossless result. Deflate work can use the standard backend or an optional Zopfli path; alpha optimization and metadata stripping are configurable passes.
Tech Stack — Rust 2024 edition (MSRV 1.85.1). It uses a multithreaded design for the optimization trials, with optional feature flags for zopfli, parallel, and filetime. A Dockerfile publishes multi-arch images, and an xtask crate handles repo automation.
Code Quality — The project is actively developed with 80 releases, a documented MSRV, a SECURITY.md, and a tests/ directory plus benches/. The README explicitly advises disabling the binary feature for library use, showing attention to how the crate is consumed in both modes.
API Design — As a CLI the options are discoverable and combinable (short flags like -savvo6 expand to full options); as a library the single Options + optimize entry point keeps embedding simple. Feature flags let library users trim unused CLI dependencies cleanly.