List pngs or jpgs which are bigger than they need to be. Can optionally compress them, but is designed mainly to keep an eye on a tree of images to make sure they stay in good shape.

Prerequisites

At least one of pngcrush or jpegran.

On Mac:

sudo port install pngcrush jpeg

On Ubuntu:

sudo apt-get install pngcrush libjpeg-progs

Install

sudo gem install squeezem

Usage

List files which could benefit from squeezing, suitable for running from cron:

squeezem path/to/images ...

Example output:

test/apple.png
test/banana.png
test/pear.png
...
11 files out of 12 could save 192972 out of 229834 (83.96)%. 17 files ignored.

Results of processing previously seen files are cached, so only new or changed files are processed. The cache lives in ~/.squeezem-cache, and is keyed by canonical filename, so you can pass different paths to the same file and it will only be reprocessed when it changes.

eg. a.png will only be processed once:

squeezem /web/images/a.png
cd /web/images
squeezem a.png

Squeeze ‘em. Compresses files in-place:

squeezem --squeezem .

Forces previously seen files to be reprocessed:

squeezem --ignore-cache .

Related

github.com/grosser/smusher - does a similar job, but uses online compression services.