head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.07.11.17.38.09; author william; state Exp; branches; next 1.3; 1.3 date 2001.03.23.20.42.43; author william; state Exp; branches; next 1.2; 1.2 date 2000.09.01.18.33.49; author william; state Exp; branches; next 1.1; 1.1 date 2000.09.01.18.31.46; author william; state Exp; branches; next ; desc @@ 1.4 log @*** empty log message *** @ text @#!/bin/sh # Script to convert an arbitrary PostScript image to an encapsulated # PostScript image with a bitmap, suitable for incorporation into # FrameMaker, LaTeX, troff, etc. # # Options: # -gs Use ghostscript to convert to EPSI # -news Use Sun's X/NeWS (OpenWindows) to convert to EPSI # -strip Strip all %% directives from the source file -- useful # when dealing with Adobe Illustrator and others who # use directives incompatible with this coversion. # -2x Use 2x resolution # -noprev Do not include the preview bitmap # # Note in the USAGE line below, the source PostScript file must end # in a .ps extention. This is a GhostScript requirement, not mine... # # I am providing this without any guarantee. # # Thu Nov 29 10:57:05 EST 1990 - Doug Crabill dgc@@cs.purdue.edu # Original release. # # Sun Jan 11 02:47:26 EST 1998 - William C. Cheng # Handles Aladdin Ghostscript 5.x (no pstoppm.ps). # Thu May 20 11:29:12 EDT 1999 - William C. Cheng # Handles the "-2x" command line argument (needs netpbm-20may1999). # Fri Sep 1 14:32:15 EDT 2000 - William C. Cheng # Make the default STYLE to be "ppm". # Fri Mar 23 11:18:17 PST 2001 - William C. Cheng # Handles the "-noprev" command line argument. USAGE="Usage: $0 [ -gs | -news ] [ -strip ] [ -2x ] [-noprev] \ .ps .epsi" ########################## Edit these variables ##################### GS='/usr/local/bin/X11/gs' PSTOPPM='/usr/local/libdata/X11/gs/pstoppm.ps' PBMTOEPSI='./pbmtoepsi' RASTTOPNM='/mm/bin/rasttopnm' INTERP='gs' STRIP='false' HIRES='false' PREVIEWBITMAP='true' PSTORAST='./pstorast' ###################################################################### GSCOPYRIGHT=`$GS -help | grep Ghostscript` ALADDIN=`echo $GSCOPYRIGHT | grep Aladdin` GSVERSION=`echo $GSCOPYRIGHT | cut -d" " -f3 | cut -d"." -f1` for A do case $A in -gs) INTERP='gs' shift ;; -news) INTERP='news' shift ;; -strip) STRIP='true' shift ;; -2x) HIRES='true' shift ;; -noprev) PREVIEWBITMAP='false' shift ;; *) break ;; esac done BASE=`basename "$1" .ps` if [ $# -ne 2 -o ! -f "$1" -o "$1" = "$BASE" ] ; then echo $USAGE 1>&2 exit 1 fi TMP1="/tmp/$USER.1.$$" TMP2="/tmp/$USER.2.$$" TMP3="/tmp/$USER.3.$$" trap 'rm -f $TMP1 $TMP2 ${BASE}.ppm; exit' 1 2 3 4 13 15 if [ "true" = "$STRIP" ] ; then awk '/^%%/ { next } {print}' < $1 > $TMP3 else TMP3="$1" fi if [ "gs" = "$INTERP" ] ; then STYLE="none" STYLE="ppm" GSFLAGS="-q -dBATCH -dNOPAUSE -sDEVICE=pbm" if [ "" != "$ALADDIN" ] ; then if [ "3" = "$GSVERSION" -o "4" = "$GSVERSION" ] ; then STYLE="pstoppm" STYLE="ppm" GSFLAGS="-q -dNOPAUSE -sDEVICE=pbm" fi if [ "5" = "$GSVERSION" ] ; then STYLE="ppm" GSFLAGS="-q -dNOPAUSE -sDEVICE=pbm" fi if [ "6" = "$GSVERSION" ] ; then STYLE="ppm" fi else if [ "2" = "$GSVERSION" ] ; then STYLE="pstoppm" GSFLAGS="-q -dNOPAUSE -sDEVICE=pbm" fi ############################################# # if [ "$GSVERSION" >= 3] set STYLE = "ppm" # ############################################# fi if [ "none" = "$STYLE" ] ; then echo Does not know how to handle "$GSCOPYRIGHT". exit 1 fi if [ "pstoppm" = "$STYLE" ] ; then $GS -q -dNODISPLAY $PSTOPPM << DGC ($BASE) ppm1run DGC fi if [ "ppm" = "$STYLE" ] ; then if [ "false" = "$HIRES" ] ; then $GS ${GSFLAGS} -sOutputFile=${BASE}.ppm -- "$1" else $GS ${GSFLAGS} -r144x144 -sOutputFile=${BASE}.ppm -- "$1" fi fi if [ "false" = "$HIRES" ] ; then $PBMTOEPSI ${BASE}.ppm > $TMP1 else $PBMTOEPSI -scale 0.5 ${BASE}.ppm > $TMP1 fi if [ "true" = "$PREVIEWBITMAP" ] ; then cat $TMP1 $TMP3 > $2 else head -2 $TMP1 > $2 cat $TMP3 >> $2 fi else $PSTORAST -in $TMP3 -out $TMP1 $RASTTOPNM < $TMP1 | $PBMTOEPSI > $TMP2 cat $TMP2 $TMP3 > $2 fi if [ "$1" != "$TMP3" ] ; then rm -f $TMP3 fi rm -f $TMP1 $TMP2 ${BASE}.ppm exit 0 # # @@(#)$Id: pstoepsi,v 1.3 2001/03/23 20:42:43 william Exp william $ # @ 1.3 log @*** empty log message *** @ text @d94 1 d99 1 d103 1 d111 1 d113 3 a115 12 if [ "3" = "$GSVERSION" ] ; then STYLE="ppm" fi if [ "4" = "$GSVERSION" ] ; then STYLE="ppm" fi if [ "5" = "$GSVERSION" ] ; then STYLE="ppm" fi if [ "6" = "$GSVERSION" ] ; then STYLE="ppm" fi d128 1 a128 1 $GS -q -dNOPAUSE -sDEVICE=pbm -sOutputFile=${BASE}.ppm -- "$1" d130 1 a130 1 $GS -q -dNOPAUSE -r144x144 -sDEVICE=pbm -sOutputFile=${BASE}.ppm -- "$1" d158 1 a158 1 # @@(#)$Id: pstoepsi,v 1.2 2000/09/01 18:33:49 william Exp william $ @ 1.2 log @*** empty log message *** @ text @d13 1 d29 2 d32 2 a33 1 USAGE="Usage: $0 [ -gs | -news ] [ -strip ] [ -2x ] .ps .epsi" d43 1 d65 3 d143 6 a148 1 cat $TMP1 $TMP3 > $2 d163 1 a163 1 # @@(#)$Id: pstoepsi,v 1.1 2000/09/01 18:31:46 william Exp william $ @ 1.1 log @Initial revision @ text @d26 2 d85 1 d150 1 a150 1 # @@(#)$Id$ @