However, whenever I fix problems, I have to do the same procedure. It was very cumbersome procedures. I decide to make a lazy program, which do the same thing automatically. Here my second python script :
#!/usr/bin/python # License : http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en # Module: fixBBox.py # Author: Jeong Han Lee # email : citadel.lee@gmail.com # Date: 2007/11/08 # Version: 0.0.2 # # 2007.11.07 0.0.1 created # 2007.11.08 0.0.2 # 1. the boundingbox information correctly # in the following possible 4 situations: # @ %%BoundingBox: is or is not # @ %%HiResBoundingBox: is or is not # 2. fixed the no response when an empty file is used as an input
import os, sys import glob import re from subprocess import Popen, PIPE
def get_filenames(args): results = [] for a in args: #http://docs.python.org/lib/module-glob.html l = glob.glob(a) if len(l) > 0: results = results + l else: print 'There is no',a,'file. Please confirm your file name.' sys.exit() return results
2008.3.28 One guest pointed out a bug in the above script as
Thanks for this great script. But there is a small bug in the regexp.
The Bbox can also contain negative numbers, in which case the compiled
regular expressions won't replace the BBox string. To fix it replace in the syntax_* variables '[\d ]+' with '[\-\d ]+'
I really appreciate this comment since this is the first and unique feedback. However, the suggestion is not enough to apply the real eps file when I realize ghostscript does not reply the correct bounding box information even if I change the regular expressions. I found the useful note (see page 18) : http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf.
To fix these bug, I must redesign all python script. It also is a time-consuming work for me because I am not a professional programmer. Anyway, this is a sort of TODO list.
If you suffer from the negative bounding box informations, consult the adobe info booklet or try to understand the following differences. I think you will find the solution.