#!/bin/sh # Iain Murray. April 2005. # I note there's a Debian package epstool that does this and more # I didn't have internet access at the time... set -e if [ "$#" -ne 2 ] ; then echo This script fixes the bounding box on eps files. echo It is a wrapper around gs. I have tested on version echo 'ESP Ghostscript 7.07 (2003-07-12)' echo echo Usage: "$0" origfile.eps fixedfile.eps exit 1 fi if [ \! -r $1 ] ; then echo Unable to read input file: "$1" exit 1 fi if BBOX=`gs -q -dNOPAUSE -dBATCH -sDEVICE=bbox "$1" 2>&1` ; then sed 'q' "$1" > "$2" echo "$BBOX" >> "$2" sed -e '1d' -e '/^%%BoundingBox:/d' "$1" >> "$2" else echo "Sorry I don't understand file $1" exit 1 fi