• Stars
    star
    3,351
  • Rank 13,365 (Top 0.3 %)
  • Language
    Python
  • License
    Other
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Insane(ly slow but wicked good) PNG image optimization

Crunch PNG file optimizationCrunch PNG file optimization Crunch PNG file optimization

GitHub release Linux Python CI macOS Python CI Lints Benchmarks

About

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).

Continuous benchmark testing is available in our GitHub Actions CI. Please see the benchmarks directory of this repository for details about the benchmarking approach and instructions on how to execute benchmarks locally on the reference images distributed in this repository or with your own image files.

Crunch PNG image optimization is available through the following applications that are distributed 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 or the Windows subsystem for Linux
  • 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

Installation and Usage

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

crunch Command Line Executable

The crunch command line executable can be installed with make or manually. Please see the Install documentation.

Enter paths to your PNG image files as arguments to the crunch executable. Please see the Usage documentation.

Crunch macOS GUI Application

The Crunch native macOS GUI application can be installed with Homebrew or the dmg installer that can be downloaded from the repository releases. Please see the Install documentation.

Drag and drop one or more images on the application window to process your PNG files. Please see the Usage documentation.

Crunch Image(s) macOS Right-Click Menu Service

The macOS right-click menu service "Crunch Image(s)" can be installed with make or manually by drag and drop in the macOS Finder. Please see the Install documentation.

Select one or more PNG images in the Finder, right-click, and select the Services > Crunch Image(s) menu item to process your files. Please see the Usage documentation.

Contents

Examples

The following examples demonstrate the benefits and disadvantages of the current iteration of Crunch's aggressive space saving optimization strategy. The optimized image files are updated at every Crunch release. In many cases, the PNG optimization decreases file size with an imperceptible impact on image quality. In some cases, degradation of image quality is visible. Visual confirmation of image quality is highly recommended with lossy optimization tools in production settings.

Photography Examples

Cat Image

  • Original Size: 583,398 bytes
  • Optimized Size: 196,085 bytes
  • DSSIM similarity score: 0.001383
  • 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.000920
  • 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.002923
  • 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.003047
  • 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.002450
  • 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.001013
  • 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.

DSSIM testing was performed with v2.10.0 of the kornelski/dssim tool.

Issue Reporting

Have you identified a problem? Please create a new issue report on the Github issue tracker so that we can address it.

Licenses

Crunch is licensed under the MIT license.

Embedded Software

pngquant is licensed under the Gnu General Public License, version 3. The pngquant source code is available here.

zopflipng is licensed under the Apache License, Version 2.0. The upstream zopflipng source code is available here. The source for the modified zopflipng fork that is used in this project is available here.

See the LICENSE.md document for details and additional licensing information for this project.

Contributing

Contributions to the project are warmly welcomed. Please suggest enhancements as new issue reports on this repository. Source contributors should fork the git repository and submit changes as a Github pull request.

Acknowledgments

Crunch is a simple tool that makes excellent, free, open source software built by others more accessible. The hard work on the optimization engines that run Crunch has been performed by:

The fantastic macOS GUI animations were designed by Gary Jacobs.

More Repositories

1

codeface

Typefaces for source code beautification
Python
6,026
star
2

cinder

A clean, responsive MkDocs theme
HTML
204
star
3

fontname.py

Font renaming script for OpenType tables in CFF (.otf) and OT TrueType (.ttf) fonts
Python
134
star
4

naked

A Python command line application framework
Python
119
star
5

crypto

Simple symmetric GPG file encryption and decryption
Python
44
star
6

macosx-versions-cleaner

A script that scrubs the document version history from OS X systems
Python
44
star
7

six-four

A base64 encoder for images that embeds encoded image data in HTML, Markdown, CSS, LESS, or SASS files at the site of an embed tag
Python
26
star
8

chug

Simple, clickable Homebrew package management for macOS
Shell
24
star
9

octopus

A command line tool that simplifies and extends the management tasks of the Octopress & Jekyll website framework
C++
20
star
10

commandlines

A Python command line argument to object parsing library for command line application development
Python
14
star
11

shellescape

Shell escape a string to safely use it as a token in a shell command (backport of Python shlex.quote)
Python
14
star
12

scriptacular

Generic, reusable bash shell scripts
Shell
11
star
13

dsh

A command line search interface to the programming language/framework docsets in the Mac OSX application, Dash. Includes language specific documentation filters.
Ruby
11
star
14

snowball

A light, clean Markdown text editor theme for the Mou and Lightpaper Markdown editors
Shell
9
star
15

md2rst

Markdown to reStructuredText conversion script
Shell
8
star
16

vectora

A Rust library for n-dimensional vector computation with real and complex scalar data
Rust
7
star
17

glue-docs

Documentation for Glue
JavaScript
7
star
18

swizzle

A dark Markdown theme for the Mou and Lightpaper Markdown text editors
Shell
7
star
19

ink

A fast, flexible stream editor for text
Go
6
star
20

path

View system PATH as an ordered list
C
6
star
21

jampack

Simple file archives for everyone (works on OS X, Linux, & Windows)
Python
5
star
22

PyDOC

A Sublime Text plugin that supports Python 2/3 & select Python package documentation search from selections in the editor
Python
5
star
23

hsh

Simple cross-platform file hash digests and file integrity checks
Python
5
star
24

pull

Simple OS X copy and click file pulls + git repository clones from the clipboard
Shell
4
star
25

py-skeleton

Python command line application skeleton
Python
4
star
26

notis

Mac OSX toast message notification utility for long-running command line applications (with optional audio signal)
Ruby
4
star
27

helpy

Python built-in help documentation from the command line (without the interactive Python interpreter console)
Python
3
star
28

hl

A pipeline syntax highlighting tool
Rust
2
star
29

greedy-palettization

Automatically exported from code.google.com/p/greedy-palettization
C++
2
star
30

naked-docs

Documentation for Naked
HTML
2
star
31

recurse

Cross-platform recursive directory traversal file management tool
Rust
2
star
32

cgeo

A Rust 2D computational geometry library
Rust
1
star
33

redact

Rust
1
star
34

shugr

A cross-platform, web browser-based Emmett HTML editor.
JavaScript
1
star
35

cssDOC

A Sublime Text plugin that supports CSS documentation search from selections in the editor
Python
1
star
36

climock

A command line executable file that returns user-defined mock standard output stream text, standard error stream text, and exit status code testing data
Go
1
star
37

commandlines-rust

A command line argument parsing library for Rust
Rust
1
star
38

fontrenderdiff

Norbert Lindberg's FontRenderDiff tool for macOS
Swift
1
star
39

vectora-benchmarks

Rust
1
star
40

center-of-mass-diff

Analysis of center of mass and area calculations for use in diff of font glyphs between builds
Python
1
star
41

fontmake-bisection-tests

1
star
42

technicolor

Rust
1
star
43

pylib

Python library project skeleton
Python
1
star
44

regular

A Python wrapper for the Rust regex regular expression library
Python
1
star
45

status

Report the HTTP status codes for GET and POST requests
Python
1
star
46

scripts

personal script repository
Python
1
star
47

blocks

a text file templating engine
C++
1
star
48

siz

A versatile, cross-platform command line file size reporting executable with default recursive file system traversal
Rust
1
star
49

markdown-cheat-sheet

A cheat sheet for the Markdown syntax, written in Markdown...
1
star
50

feature-size-analysis

Jupyter Notebook
1
star
51

gluedrops

Extensions for the Glue Sublime Text plugin
JavaScript
1
star
52

opsz-rvrn-demo

1
star
53

gf-languages

1
star
54

standardstreams

Python standard output, standard error, and standard input stream library
Python
1
star
55

chunky

Asynchronous, concurrent, chunked Python HTTP requests for files
Python
1
star
56

stylename.py

OpenType name table nameID 2 and 17 record editing tool
Python
1
star
57

OSXEmptyTrash

Double-click trash empty for OS X (that bypasses the pesky Item In Use block)
Shell
1
star
58

ufo-format-diff

Python
1
star
59

python-progressbar

Automatically exported from code.google.com/p/python-progressbar
Python
1
star
60

lorem

A dummy text generator and text replacement tool that embeds text in existing files, creates new text files, and writes text to the standard out stream. Will write up to 1 million paragraphs (and can be recompiled with this restriction modified)
Shell
1
star