psfixbb - fix the BoundingBox in a Postscript file.
psfixbb [-ceflr] [-x N] [-o outfile] filename [filename...]
psfixbb is a tool to create a BoundingBox in Postscript(R)
files
which do not have one, or to fix an incorrect existing BoundingBox.
Many applications write Postscript(R)
files or Encapsulated
Postscript(R)
files with no or incorrect BoundingBox information.
I.e. the box which contains the image or text on the page is often
smaller than specified in the %%BoundingBox comment in the file. This
can be annoying when importing the file into other documents.
psfixbb computes the size of the used part of a page and inserts
the information into the file.
psfixbb uses ghostscript (gs) to transform the page into a portable bit map (pbm), then the pnmfile and pnmcrop utilities to determine the size of the non-white part of the page. These three programs need to be installed for psfixbb to work.
Because psfixbb really looks at the dark pixels of the page, it works even if the application which produced the Postscript file has painted the background of the whole page white. Most other boundingbox-fixing utilities choose the entire page in such cases. When the BoundingBox is smaller then the white background, it may be necessary to tell your text program to clip the image when importing it. For example, in LaTeX you need to specify ``clip='' as a parameter to the \includegraphics macro.
For landscape figures, it may or may not be necessary to rotate the page (using the -r switch) before attempting to compute the bounding box .
Carsten Dominik <dominik@strw.LeidenUniv.nl>
Holger Karl <karl@informatik.hu-berlin.de>
This program is free software. See the source file for the full copyright notice.
For the file file.ps, file.ps.bak is used as a temporary file.
gs(1), pnmfile(1), pnmcrop(1), pnm(5)
psfixbb does not work for images larger than a normal page.
Rotation of landscape files should really be automatic, but I don't know a general way to determine if this is necessary of not. Suggestions are welcome.
The file file.ps.bak is overwritten without checking.
For multipage documents, only the first page determines the value of the BoundingBox.
Thanks to Georg Drenkhahn for pointing out how to enforce a showpage command in gs.