Created
July 5, 2014 23:40
-
-
Save TakashiUNUMA/2a3f9213836411133220 to your computer and use it in GitHub Desktop.
A shell script for modifying the bounding box of the input eps files using ghostscript.
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 | |
# | |
# modify_boundingbox.sh | |
# | |
# original script coded by Takashi Unuma, Kyoto Univ. | |
# last modified: 2014/07/06 | |
# | |
# required commands: basename, gs, sed, and awk | |
# | |
# check arguments | |
if test $# -lt 1 ; then | |
echo "USAGE: $(basename $0) [EPS file(s)]" | |
exit | |
fi | |
# execute section | |
for file in $* ; do | |
# get a "true" bounding box information in the specified eps file | |
bbinfo=$(gs -q -dNOPAUSE -dBATCH -sDEVICE=bbox ${file} 2>&1 | sed -e "s/\%/\\\%/g" -e "s/\:/\\\:/g" -e "s/\./\\\./g" -e "s/[[:blank:]]/\\\ /g" | awk '{printf $0}') | |
# overwrite the information of bounding box | |
sed -i -e "2c${bbinfo}" -e "3d" ${file} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment