#!/bin/sh # This shell script will convert .dvi or .ps files into gifs. # Runs on Cartan or Poincare. # # Adapted from similar scripts at http://cgm.cs.mcgill.ca/~luc/postscript.html. # # usage: mathtogif [options] filename[.ps, .dvi] [more files] # # If .dvi is specified or if a .ps file cannot be found, dvips is run. # Options can be -crop to crop the gif, or ghostscript options (man gs) # such as -r75x75 to specify the resolution. We made -r100x100 the # default as this seems to give good results. Options must preceed # the filename or they are ignored. # # Author: Daniel Bump (bump@math) LD_LIBRARY_PATH=/lib:/usr/lib:/usr/openwin/lib PATH=/usr/bin:/usr/local/netpbm:/usr/local/bin:/bin export PATH LD_LIBRARY_PATH if (test $# = 0) || (test $1 = "-h") || (test $1 = "-help") then echo "" echo "usage: mathtogif [options] filename[.ps, .dvi] [more files]" echo "" echo "If .dvi is specified or if a .ps file cannot be found, dvips is run." echo "Options can be -crop to crop the gif, or ghostscript options (man gs)" echo "such as -r75x75 to specify the resolution. We made -r100x100 the" echo "default as this seems to give good results. Options must preceed" echo "the filename or they are ignored." echo "" exit 1; fi gsparams="" CROP="false" for i in $* do if test `echo $i|sed 's/^-.*/-/g'` = "-" then if test $i = "-crop" then CROP="true" else gsparams=$gsparams" "$i fi else basefile=`echo $i|sed s/\.ps$//g|sed s/\.dvi$//g` if (test ! -f $basefile.ps) || (test $1 = $basefile.dvi) then dvips -o $basefile.ps $basefile.dvi fi gs -sDEVICE=ppmraw -sOutputFile=$basefile%d.ppm -dNOPAUSE -r100x100 $gsparams $basefile.ps `echo $j|sed s/\.ppm/\.gif/g` rm $j done else for j in $basefile*.ppm do ppmtogif $j >`echo $j|sed s/\.ppm/\.gif/g` rm $j done fi fi done