#!/bin/sh cmd=$(basename $0) usage() { echo "usage: $cmd [-g] [-r] file" exit 1 } while getopts ":g:r:G" c do case "$c" in g) gamma="-replace_gamma $OPTARG";; r) res="-res $OPTARG";; G) gamma="-rem gama";; :|'?') usage;; esac done shift $(($OPTIND - 1)) if [ $# -lt 1 ]; then usage; fi for f in "$@"; do tmpfile=$(mktemp ~/.$cmd.XXXXXX) || exit 1 pngcrush -q $gamma $res "$f" $tmpfile mv -f $tmpfile "$f" && chmod go+r "$f" done .