#!/bin/sh # modified by kolar@karlin.mff.cuni.cz # - adds border to page # - density can be changed # - 'bits per pixel' can be changed (colors) # - supports GS 6 # There is a difference between GS ver. 4 and GS ver. 6 # (I do not know whether ver. 5 behaves like 4 or 6) # Script to convert an arbitrary PostScript image to a cropped GIF image # suitable for incorporation into HTML documents as inlined images to be # viewed with Xmosaic. # # This is a modified version of the pstoepsi script # by Doug Crabill dgc@cs.purdue.edu # # Note in the USAGE line below, the source PostScript file must end # in a .ps extention. This is a GhostScript requirement, not mine... # # This software is provided without any guarantee. # # Nikos Drakos, nikos@cbl.leeds.ac.uk # Computer Based Learning Unit, University of Leeds. # # Tue Jun 8 13:11:53 BST 1993 USAGE="Usage: $0 [-bpp8] [-bpp24] [] .ps .gif" ### Edit these variables if you want to run the script outside the translator ### GS=gs #PSTOPPM=/usr/net/packages/latex2html/pstoppm.ps #PNMCROP=/usr/new/pbmplus/pnmcrop #PPMTOGIF=/usr/new/pbmplus/ppmtogif #PNMMARGIN=/usr/new/pbmplus/pnmmargin PSTOPPM=/usr/local/lib/ghostscript/pstoppm.ps PNMCROP=pnmcrop PPMTOGIF=ppmtogif PNMMARGIN=pnmmargin DENSITY=100 if gs -v | egrep 'Ghostscript 3|Ghostscript 4|Ghostscript 5' >/dev/null then GSold=yes ; fi if gs -v | egrep 'Ghostscript 5' >/dev/null then echo I am not shure how to deal with Ghostscript ver. 5 1>&2 ; fi if [ $GSold ] then PPMRUN=ppm1run fi # pnmmargin vyuziva jine veci z /usr/new/pbmplus PATH=$PATH:/usr/new/pbmplus/ export PATH ###################################################################### if [ $# -lt 2 ] ; then echo $USAGE 1>&2 exit 1 fi if [ $1 = -bpp8 ] ; then PPMRUN=ppm8run; shift fi if [ $1 = -bpp24 ] ; then PPMRUN=ppm24run; shift fi if [ $# = 3 ] ; then DENSITY="$1"; shift fi BASE=`basename "$1" .ps` if [ $# -ne 2 -o "$1" = "$BASE" ] ; then echo $USAGE 1>&2 exit 1 fi if [ ! -f "$1" ] ; then echo $0: can not read file "$1" exit 1 fi trap 'rm -f ${BASE}.ppm; exit' 1 2 3 4 13 15 if [ $GSold ] then $GS -q -dNODISPLAY $PSTOPPM << ND $DENSITY $DENSITY ppmsetdensity ($BASE) $PPMRUN ND if test -f ${BASE}.ppm then $PNMCROP ${BASE}.ppm |$PNMMARGIN -white 5| $PPMTOGIF - > $2 #nasledujici samozrejme ingoruje $2 else for i in `ls ${BASE}.[0-9]*ppm` # JanKo: above was [1-9], strange, I would write [0-9]* do $PNMCROP $i |$PNMMARGIN -white 5| $PPMTOGIF - > `echo $i |sed 's/\.\(.*\)ppm/\1\.gif/'`; echo "Writing `echo $i |sed 's/\.\(.*\)ppm/\1\.gif/'`" 1>&2 done fi rm -f ${BASE}.ppm rm -f ${BASE}.[0-9]*ppm else pstopnm -xborder 0.0 -yborder 0.0 -xmax 900 -ymax 1400 -portrait $BASE # -verbose -nocrop if test -f ${BASE}002.ppm then #nasledujici samozrejme ingoruje $2 for i in `ls ${BASE}[0-9]*ppm` do $PNMCROP $i | $PPMTOGIF - > `echo $i |sed 's/\.\(.*\)ppm/\1\.gif/'` echo "Writing `echo $i |sed 's/\.\(.*\)ppm/\1\.gif/'`" 1>&2 done else $PNMCROP ${BASE}001.ppm | $PPMTOGIF - > $2 fi rm -f ${BASE}.ppm rm -f ${BASE}[0-9]*ppm fi exit 0