JPG resize shell script
Script, which resize all argumented jpg files to requested width or height.
#!/bin/bash
# resize all specified jpg files to requested width x height
# required: jpegtopnm, pnmscale, pnmtojpeg
# johniez, http://johniez.com
# init version - backup your data before ;)

TMP_FILE1=/tmp/tmp_file1_$$
TMP_FILE2=/tmp/tmp_file2_$$
WIDTH=800
HEIGHT=600

function usage() {
	echo Usage:
	echo $0 -w width -h height files.jpg
}

while getopts "?w:h:" CHOOSE
do
	case $CHOOSE in
	\?)	usage;;
	w)	WIDTH=$OPTARG;;
	h)	HEIGHT=$OPTARG;;
	esac
done

shift $(($OPTIND-1))

for i in $*; do
	jpegtopnm "$i" > "$TMP_FILE1"
	pnmscale --width $WIDTH --height $HEIGHT "$TMP_FILE1" > "$TMP_FILE2"
	pnmtojpeg "$TMP_FILE2" > "$i"
done

rm -f $TMP_FILE1 $TMP_FILE2

exit 0