home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / unixtex-6.1b-src.lha / unixtex-6.1b / dviljk / contrib / epspcl < prev    next >
Encoding:
Text File  |  1994-09-17  |  1.8 KB  |  77 lines

  1. #! /usr/local/bin/bash
  2. # Date: Fri, 11 Feb 1994 13:12:15 -0500
  3. # From: norm@ora.com (Norman Walsh)
  4. #
  5. # Usage: gs-eps epsfile <outputfile> <resolution> <device>
  6. #
  7. # Where: epsfile is the encapsulated postscript file
  8. #        outputfile is the output file (default=<basename epsfile>.device)
  9. #        <resolution> is the output resolution desired (default=300dpi)
  10. #        <device> is the GS driver to use (default=pbm)
  11.  
  12. EPSFILE=$1
  13. OUTPUTFILE=$2
  14. RES=$3
  15. DEVICE=$4
  16.  
  17. if [ "$RES" = "" ]; then
  18.   RES=300
  19. fi
  20.  
  21. if [ "$DEVICE" = "" ]; then
  22.   DEVICE=pbm
  23. fi
  24.  
  25. if [ "$EPSFILE" = "" ]; then
  26.   echo "Usage: `basename $0` epsfile <outputfile> <resolution> <gsdriver>" 
  27.   echo "Note: parameters are positional, to specify a driver you must also"
  28.   echo "specify the outputfile and resolution."
  29.   exit 1
  30. fi
  31.  
  32. if [ "$OUTPUTFILE" = "" ]; then
  33.   OUTPUTFILE=`basename $EPSFILE .eps`.$DEVICE
  34. fi
  35.  
  36. echo "Converting $EPSFILE to $DEVICE at ${RES}dpi..." 
  37.  
  38. BBOX=`egrep -i "^%%BoundingBox:[ ]*[0-9]+ [0-9]+ [0-9]+ [0-9]+[ ]*" $EPSFILE`
  39.  
  40. if [ "$BBOX" = "" ]; then
  41.   echo "Cannot find bounding box in $EPSFILE"
  42.   exit 1
  43. fi
  44.  
  45. # move $BBOX into $1, $2, etc...
  46. set $BBOX
  47.  
  48. LLX=$2
  49. LLY=$3
  50. URX=$4
  51. URY=$5
  52.  
  53. XSIZE=`expr $URX - $LLX`
  54. YSIZE=`expr $URY - $LLY`
  55.  
  56. XSCALE=`expr $XSIZE "*" $RES`
  57. XSIZE=`expr $XSCALE / 72`
  58.  
  59. YSCALE=`expr $YSIZE "*" $RES`
  60. YSIZE=`expr $YSCALE / 72`
  61.  
  62. echo $LLX neg $LLY neg translate > gs-eps-a.$$
  63. echo "quit" > gs-eps-b.$$
  64.  
  65. SHOWPG=`grep -i showpage $EPSFILE`
  66. if [ "$SHOWPG" = "" ]; then
  67.   echo "$EPSFILE does not seem to include a PostScript \"showpage\" command."
  68.   echo "so I'm appending one for you.  If this is incorrect...???"
  69.   echo "showpage" > gs-eps-b.$$
  70.   echo "quit" >> gs-eps-b.$$
  71. fi
  72.  
  73. gs -sDEVICE=$DEVICE -q -sOutputFile=$OUTPUTFILE -g${XSIZE}x${YSIZE} \
  74.    -r$RES gs-eps-a.$$ $EPSFILE - < gs-eps-b.$$
  75.  
  76. rm -f gs-eps-a.$$ gs-eps-b.$$
  77.