#! /bin/sh

PAGES="1 2 3 4 5 6 7 8 9"

#Widths: 1728, 2048, 2432
WIDTH=1728

#Heights: 2166, 2292, 2810
HEIGHT=2166

#Vert Res: 98, 196 (DPI)

# parse command line
while test $# != 0; do
    case "$1" in
	-f) FILE=$2; shift;;
	-c) PAGECOUNT=$2; shift;;
	-h) HIRES=YES;;
	*) ;;
    esac
    shift
done
for i in $PAGES; do ( 
	if [ -f $FILE'.''00'$i ]; then
		if [ HIRES ]; then
			echo "High Res"
			echo -n '010' > 'FAX'$FILE'.''00'$i
			OPS=-s
		else
			echo "Low Res"
			echo -n '000' > 'FAX'$FILE'.''00'$i
			OPS=-d
		fi
		cat $FILE'.''00'$i >> 'FAX'$FILE'.''00'$i
	fi
); done
touch 'FAX'$FILE'.fax'
/usr/lib/NextPrinter/faxcleanup -M -Q -w $WIDTH -X $OPS $PAGECOUNT 'FAX'$FILE


