#! /bin/sh # Shell script to convert a PostScript file to a gif file. The hard work is # done by Ghostscript; you must have this available in order for the script # to function properly. Final massaging of the text gets done by programs in # the netpbm (portable bitmap manipulation) package, which also must be # installed for the script to work. n=0 what=- density=72 depth=1 tmp=/tmp/pstogif$$ ppmargs= cmd="sed -e s/showpage//g" dirpps=/usr/share/data/ghostscript trans='-transparent rgb:ff/ff/ff' while [ $# -gt 0 ]; do case "$1" in -density) density="$2" ; shift ;; -depth) depth="$2" ; shift ;; -interl*) ppmargs="${ppmargs} $1" ;; -notrans*) trans="" ;; -noedit) cmd="cat -" ;; *) n=`expr $n + 1` if [ $n = 1 ]; then if [ 0 != `expr "$1" : .*\.ps` ]; then what=`expr "$1" : '\(.*\)\.ps'` else echo "$0: File name $1 must end with .ps" fi else echo "$0: Dont understand $1" > /dev/tty exit 1 fi ;; esac shift done if [ "$what" = "-" ]; then echo "$0: No file input given." exit 1 fi cat << EOF > $tmp $density $density ppmsetdensity ppmsetsize2a4 (${what}) ppm${depth}run EOF cat $tmp $what.ps | $cmd | gs -q -dNODISPLAY $dirpps/pstoppm.ps - if [ -f $what.ppm ]; then pnmcrop $what.ppm | ppmtogif $trans > $what.gif /bin/rm -f $what.ppm else for i in `echo $what.[1-9]*ppm` ; do j="`expr $i : '\(.*\)ppm'`.gif" pnmcrop $i | ppmtogif $trans $ppmargs > $j /bin/rm -f $i done fi /bin/rm -f $tmp