#!/bin/bash # # ps2gif C shell script # David Manning # 11 December 1995 # # This program converts a Postscript file to a gif file. # It accomplishes this is a couple of steps: # 1. Convert from ps to ppm file (using Ghostscript and ps2ppm) # 2. Rotate file. The Postscript file was written to print # in landscape format. Now, we need to undo this. # 3. Convert file from ppm to gif (ppmtogif) # # We also extract the total x and y coordinates from the ppm file # before deleting it. # # input: $1 filename of .ps file # # output: $1.gif gif output file # $1.tmp coordinate information of gif file # # required programs and files: # gs Ghostscript (convert to ppm) # pstoppm.ps Ghostscript input file # pnmrotate To rotate ps file 90 deg. counterclockwise # ppmtogif Convert ppm file to gif # # variables: # XPATH The path of pnmrotate and ppmtogif # # Temporary files: # $1.ppm Output of the ps2ppm conversion. # $1.ppm2 Output of pnmrotate. # $1.in Input to Ghostscript command #---------------------------------------------------------------- #setenv XPATH /usr/bin/X11 # # Create the $1.in file # echo "($1) ppm1run" > $1.in echo "quit" >> $1.in # # Write (echo) some pretty output # echo -n "Converting ps to gif .." # # Run Ghostscript # gs -q -dNODISPLAY pstoppm.ps < $1.in 2&> /dev/null # # more pretty output # echo -n ".." # # Let's rotate the file 90 degrees counterclockwise # /usr/bin/X11/pnmrotate 90 $1.ppm > $1.ppm2 2> /dev/null # # more pretty output # echo -n ".." # # Let's convert from ppm to gif # /usr/bin/X11/ppmtogif $1.ppm2 > $1.gif 2> /dev/null # # more pretty output # echo -n ".." # # Some cleanup is required... # rm -f $1.in rm -f $1.ppm # # gotta have the pretty output # echo -n ".." # # extract coordinates of gif file # #head -2 $1.ppm2 | tail -1 > $1.tmp # # More cleanup work # rm $1.ppm2 # # We're all done! # echo "done"