home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / ps2eps / pstoepsi < prev    next >
Text File  |  1991-04-10  |  2KB  |  86 lines

  1. #!/bin/sh
  2. # Script to convert an arbitrary PostScript image to an encapsulated
  3. # PostScript image with a bitmap, suitable for incorporation into
  4. # FrameMaker, LaTeX, troff, etc.
  5. #
  6. # Options:
  7. #    -gs    Use ghostscript to convert to EPSI
  8. #    -news    Use Sun's X/NeWS (OpenWindows) to convert to EPSI
  9. #    -strip    Strip all %% directives from the source file -- useful
  10. #        when dealing with Adobe Illustrator and others who
  11. #        use directives incompatible with this coversion.
  12. #
  13. # Note in the USAGE line below, the source PostScript file must end
  14. # in a .ps extention.  This is a GhostScript requirement, not mine...
  15. #
  16. # I am providing this without any guarantee.
  17. #
  18. # Thu Nov 29 10:57:05 EST 1990
  19. #
  20. # Doug Crabill dgc@cs.purdue.edu
  21.  
  22. USAGE="Usage: $0 [ -gs | -news ] [ -strip ] <file>.ps <file>.epsi"
  23.  
  24. ########################## Edit these variables #####################
  25. GS='/usr/local/gnu/gs'
  26. PSTOPPM='/usr/local/gnu/lib/gs/pstoppm.ps'
  27. PBMTOEPSI='/usr/local/pbm/pbmtoepsi'
  28. RASTTOPNM='/usr/local/pbm/rasttopnm'
  29. INTERP='gs'
  30. STRIP='false'
  31. PSTORAST='./pstorast'
  32. ######################################################################
  33.  
  34. for A do
  35.     case $A in
  36.     -gs)    INTERP='gs'
  37.         shift
  38.         ;;
  39.     -news)    INTERP='news'
  40.         shift
  41.         ;;
  42.     -strip)    STRIP='true'
  43.         shift
  44.         ;;
  45.     *)    break
  46.         ;;
  47.     esac
  48. done
  49.  
  50. BASE=`basename "$1" .ps`
  51.  
  52. if [ $# -ne 2 -o ! -f "$1" -o "$1" = "$BASE" ] ; then
  53.     echo $USAGE 1>&2
  54.     exit 1
  55. fi
  56.  
  57. TMP1="/tmp/$USER.1.$$"
  58. TMP2="/tmp/$USER.2.$$"
  59. TMP3="/tmp/$USER.3.$$"
  60. trap 'rm -f $TMP1 $TMP2 ${BASE}.ppm; exit' 1 2 3 4 13 15
  61.  
  62. if [ "true" = "$STRIP" ] ; then
  63.     awk '/^%%/ { next } {print}' < $1 > $TMP3
  64. else
  65.     TMP3="$1"
  66. fi
  67.  
  68. if [ "gs" = "$INTERP" ] ; then
  69.     $GS -q -dNODISPLAY $PSTOPPM << DGC
  70.     ($BASE) ppm1run
  71. DGC
  72.     $PBMTOEPSI ${BASE}.ppm > $TMP1
  73.     cat $TMP1 $TMP3 > $2
  74. else
  75.     $PSTORAST -in $TMP3 -out $TMP1
  76.     $RASTTOPNM < $TMP1 | $PBMTOEPSI > $TMP2
  77.     cat $TMP2 $TMP3 > $2
  78. fi
  79.  
  80. if [ "$1" != "$TMP3" ] ; then
  81.     rm -f $TMP3
  82. fi
  83. rm -f $TMP1 $TMP2 ${BASE}.ppm
  84.  
  85. exit 0
  86.