/ Images

A tool for lossy PNG image file optimization with python

A tool for lossy PNG image file optimization with python

Crunch

Crunch is a tool for lossy PNG image file optimization. It combines selective bit depth, color type, and color palette reduction with zopfli DEFLATE compression algorithm encoding using the pngquant and zopflipng PNG optimization tools. This approach leads to a significant file size gain relative to lossless approaches at the expense of a relatively modest decrease in image quality (see example images below).

Historical benchmarks with the files included in Cédric Louvrier's PNG Test Corpus versus other commonly used PNG optimization software are available in BENCHMARKS.md.

Crunch PNG image optimization is available through the following applications in this repository:

  • crunch - a *nix command line executable that can be used on macOS, Linux, and Windows POSIX application deployment environments such as Cygwin
  • Crunch GUI - a native macOS drag and drop GUI tool
  • Crunch Image(s) service - a macOS right-click menu service for PNG images selected in the Finder

Install and Usage

Install and usage documentation links for each of the Crunch applications are available below.

Examples

The following examples demonstrate the benefits and disadvantages of the current iteration of Crunch's aggressive space saving optimization strategy. In many cases, the PNG optimization minimizes file size with an imperceptible decrease in image quality. In some cases, degradation of image quality is visible. View the horizon line in the prairie photo below for a demonstration of an undesirable artifact that is introduced with image processing. Experiment with the image types that you use and please submit a report with examples of any images where the image quality falls short of expectations for production-ready files.

Photography Examples

Cat Image

  • Original Size: 583,398 bytes
  • Optimized Size: 196,085 bytes
  • DSSIM similarity score: 0.001471
  • Percent original size: 33.61%
Original
cat example pre optimization
Optimized
cat example post optimization

Sun's Rays

  • Original Size: 138,272
  • Optimized Size: 66,593
  • DSSIM similarity score: 0.000948
  • Percent original size: 48.16%
Original
sun rays example pre optimization
Optimized
sun rays example pre optimization

Prairie Image

  • Original Size: 196,794 bytes
  • Optimized Size: 77,965 bytes
  • DSSIM similarity score: 0.002988
  • Percent original size: 39.62%
Original
prarie example pre optimization
Optimized
prarie example post optimization

Illustration Examples

Robot Image

  • Original Size: 197,193 bytes
  • Optimized Size: 67,596 bytes
  • DSSIM similarity score: 0.000162
  • Percent original size: 34.28%
Original
robot example pre optimization
Optimized
robot example post optimization

Color Circle Image

  • Original Size: 249,251 bytes
  • Optimized Size: 67,135 bytes
  • DSSIM similarity score: 0.002491
  • Percent original size: 26.93%
Original
colors example pre optimization
Optimized
colors example post optimization

Flowers Image

  • Original Size: 440,126 bytes
  • Optimized Size: 196,962 bytes
  • DSSIM similarity score: 0.000480
  • Percent original size: 44.75%
Original
748
Optimized
748

All images above were obtained from Pixabay and are dedicated to the public domain under the CC0 Public Domain Dedication.

GitHub