#!/bin/sh tmpdir=/tmp origdir=orig if [ $# -lt 2 ]; then cat < ... Runs pnmclahe after converting images to PNM, then converts back. Normally 5 by 4 tiles are used, but if the clip limit is prepended with a "g", the global CLHE is performed instead. EOF exit fi tiles=5x4 limit=${1#g} if [ "$limit" != "$1" ]; then tiles=1x1 fi shift mkdir -p $origdir while [ $# -gt 0 ]; do src="$1" trunk="${src%.*}" if [ "$trunk" = "$src" -o "${trunk/\/}" != "$trunk" ]; then trunk="$src" ext= else ext="${src#$trunk}" fi dest="$src" save=$origdir/"${trunk}_preclahe$ext" if [ -e "$save" ]; then echo "Processing previous save file $save instead of $src" src="$save" else echo "Processing $src" cp "$src" "$save" fi convert "$src" $tmpdir/runclahe-$$.ppm echo pnmclahe -t $tiles -l $limit $tmpdir/runclahe-$$.ppm $tmpdir/runclahe-$$-result.ppm pnmclahe -t $tiles -l $limit $tmpdir/runclahe-$$.ppm $tmpdir/runclahe-$$-result.ppm convert $tmpdir/runclahe-$$-result.ppm "$dest" exiftool -tagsFromFile "$src" "$dest" rm $tmpdir/runclahe-$$.ppm $tmpdir/runclahe-$$-result.ppm shift done