#!/bin/sh
# ps2gif script by Ian Hutchinson 2000.
# use at your own risk.
# You need Ghostscript and the pbmplus utilities installed. 
if [ $# -lt 2 ] ; then
       echo " Usage: ps2gif <file.ps> <file.gif> [<icon.gif>]" 1>&2
       exit 1
else 
    echo "Calling ghostscript to convert, please wait ..." >&2
    filein=$1
#Fast and small
#   gs -sDEVICE=ppmraw -sOutputFile=- -sNOPAUSE -q $filein -c showpage -c quit | pnmcrop| pnmmargin -white 10 | ppmtogif >$2
#Slow and big but grayscale antialiasing may be better in some cases.
     gs -r288 -sDEVICE=ppmraw -sOutputFile=- -sNOPAUSE -q $filein -c showpage -c quit | pnmcrop | pnmscale 0.25 | pnmmargin -white 10 | ppmtogif >$2
    shift 2
    if [ $# -eq 1 ] ;then
# Make an icon file.
       gs -sDEVICE=ppmraw -sOutputFile=- -sNOPAUSE -r12 -q $filein -c showpage -c quit | pnmcrop|  ppmtogif >$1
    fi
fi


