#!/bin/sh # # pngcrush_batch png png png... # # Run pngcrush batch-wise over a list of png files, # to compress them by the maximum amount without dataloss. # tmp=/tmp/pngcrush_batch_$$.png if [ -f $tmp ]; then echo >&2 "pngcrush_batch: temp file \"$tmp\" already exists -- ABORTING" exit 1 fi trap 'rm -f $tmp ; exit 0' 0 1 2 3 15 for i in "$@"; do echo "--------------------------------------" echo "$i" echo "--------------------------------------" pngcrush "$i" $tmp if [ $? -eq 0 -a -s $tmp ]; then mv $tmp "$i" else echo >&2 "Pngcrush failed for file \"$i\" -- ABORTING" exit 1 fi done