#! /bin/sh # psrender -- cvt PostScript to ppm or Group3 bitmap # # This is a "helper" program which lives in /usr/fisher/mipslib # and is not meant to be called directly. PATH=/york/mips/bin:/bin:/usr/bin: glog=/tmp/$$.glog otemp=/tmp/$$.ppm rc=0 trap "rm -f $glog $otemp; exit \$rc" 0 fail() { echo "psrender: $1" >&2 rc=1; exit } for sig in 1 2 3 13 15 do trap "fail \"Signal $sig!\"" $sig done xdpi=72 ydpi=72 dev=ppm while : do case "$1" in -dpi) # resolution, dots per inch xdpi="$2"; ydpi="$3" shift; shift; shift;; -m) # monochrome dev=pbm shift;; -g3) # Group3 fax dev=faxg3 shift;; -?*) fail "bad option: $1";; *) break;; esac done [ $# != 2 ] && fail "Usage: psrender [-dpi x y] [-m | -g3] in.ps out\n(either file can be -)" # compute page size by multiplying A4 dimensions by dots per inch mul() { echo "$1 $2 * 0.5 + 0 k 1 / p" | dc; } # multiply, round to nearest integer xsize=`mul $xdpi 8.2765` ysize=`mul $ydpi 11.705` # see /york/mips/bin/pstopdf gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=$dev \ -r${xdpi}x${ydpi} -g${xsize}x${ysize} -sOutputFile=$otemp \ -c save pop -f "$1" -c quit >$glog # see if there are any error msgs read xxx <$glog && { cat $glog >&2; echo >&2 fail "GhostScript failed!" } case "$2" in -) cat $otemp;; *) cp $otemp "$2";; esac