Created
September 6, 2014 10:50
-
-
Save ooharak/214cfc1b36f73befcdbb to your computer and use it in GitHub Desktop.
EPS: Calculate bounding box and fit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -ne 1 ]; then | |
echo Usage: $0 eps \> svg | |
exit 1 | |
fi | |
SRCFILE=$1 | |
BBOXFILE=$(mktemp tmp.XXXXXX) | |
trap "rm -f $BBOXFILE" EXIT | |
gs -dNOPAUSE -dBATCH -q -sDEVICE=bbox $SRCFILE > $BBOXFILE 2>&1 | |
sed -f /dev/stdin $SRCFILE <<EOS | |
/^%%[HiRes]*BoundingBox:.*atend/{;p;d;} | |
s/^%%BoundingBox:.*$/`grep '^%%BoundingBox:' $BBOXFILE`/g | |
s/^%%HiResBoundingBox:.*$/`grep '^%%HiResBoundingBox:' $BBOXFILE`/g | |
EOS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment