Oxipng
7. 8. 2020Oxipng is a multi-threaded lossless PNG compression optimizer. It can be used via a command-line interface or as a library in other Rust programs.
Install rust from rust-lang page (The one in repos is to old), follow instructions.
Relaunch shell.
Get and compile source
git clone https://github.com/shssoichiro/oxipng.git
cd oxipng
cargo build --release
cp target/release/oxipng ~/bin
Usage
oxipng *.png
Compression advantage over pngcrush seems very small, possibly faster.
Oxipng vs Pngcrush ↓
Test One ↓
A set of 33 randomly selected png files, they are of different size, some have alpha. Both pngcrush and oxipng are using their default settings.
Original
Size: 56.9 MB
Oxipng done in 27.5 seconds.
Size: 43.6 MB.
Pngcrush done in 1 minute 54 seconds.
Size: 46.6 MB.
Danger: destroyes one file rewriting it will null size (using -ow switch here).
Note: Due to one file being destroyed, it is removed from the test set.
Conclusion: Oxi is ~4 times faster and have decently better compression than pngquant on this machine and on this set. Oxi will smartly reduce colors when it makes sense, pngquant will as well, but less smartly. Pngquant is potentially dangerous with -ow switch.
p.s. If the compression is happening on the series of images, similar speeds could be achieved with pngquant and smart usage of something like gnu parallel.
Test two ↓
Trying to use gnu parallel with pngquant script. Another set of images.
Original
Size: 48,8 MB
Pngcrush
time find . -type f -iname "*.png" | parallel --gnu crush {}
done in 13.7 seconds.
Size: 48,7 MB
Oxipng done in 16.257 seconds.
Size: 48,4 MB
Conclusion: Slight speed win for pngquant in parallel mode here, but oxi with better compression. Oxi could get some speed advantage with parallel as well.
Winner ↓
Use Oxipng if you can, it’s simpler to use without any scripting, will win for single image compression every time, seems more robust as well. However pngcrush is in Debian repos. I’am assuming there is even better png crucher out there, time will tell.
Links ↓
https://squoosh.app/
https://www.youtube.com/watch?v=F1kYBnY6mwg
Note: Imgur is not happy with webp. Interestingly bpg format never took of, a miracle compared to webp.