#!/bin/sh
# writes a small version of the input jpeg in $1 to stdout.
# The second argument is the width of the target.
# We use this as a quick hack to produce previews for large jpeg files.
die(){
	echo $@
	exit 1
}

test "t$1" == t -o ! -r "$1" && die "Arg 1 must be a readable file."
test "t$2" == t && die "Arg 2 must be the target width."

djpeg "$1" | pnmscale -x $2 | cjpeg
