|
|
How do I figure out the bounding box (BoundingBox) for an encapsulated postscript file? |
Here is a section from "Using Imported Graphics in LaTeX2e"
(ftp://ftp.cdrom.com/pub/tex/ctan/info/epslatex.pdf or ftp://ftp.tex.ac.uk/tex-archive/info/epslatex.pdf):
------------ begin excerpt -------------3.2 The EPS BoundingBox By convention, the first line of a PostScript file specifies the type of PostScript and is then followed by a series of comments called the header or preamble. (Like LATEX, PostScript's comment character is %). One of these comments specifies the BoundingBox. The BoundingBox line contains four integers:
1. The x-coordinate of the lower-left corner of the BoundingBox. For example, the first 5 lines of an eps file created by gnuplot are %!PS-Adobe-2.0 EPSF-2.0 %%Creator: gnuplot %%DocumentFonts: Times-Roman %%BoundingBox: 50 50 410 302 %%EndComments Thus the gnuplot eps graphic has a lower-left corner with coordinates (50, 50) and an upper-right corner with coordinates (410, 302). The BoundingBox parameters have units of PostScript points which are 1/72 of an inch, making the above graphic's natural width 5 inches and its natural height 3.5 inches. Note that a PostScript point is slightly larger than a TEX point, which is 1/72.27 of an inch. In TEX and LATEX, PostScript points are called "big points" and abbreviated bp while TEX points are called "points" and abbreviated pt.
Single-page PostScript files without any improper commands can be converted to eps by using one of the following methods for adding a BoundingBox line. Since these methods do not check for illegal PostScript operators, they do not produce usable EPS files unless the PS files are free of forbidden operators. 1. The most convenient option is to use the ps2epsi utility distributed with Ghostscript (see Section 5), which reads the PostScript file, calculates the BoundingBox parameters, and creates an eps file (complete with a BoundingBox) which contains the PostScript graphics. The resulting file eps file is in epsi format, which means it contains a low- resolution bitmapped preview at the beginning of the file. Since this preview is ascii-encoded, it does not cause the Section 4.1 bufsize errors. However, this epsi preview increases the file size. 2. Alternatively, the BoundingBox parameters can be calculated and inserted in the PostScript file's BoundingBox line or specified in the graphics-insertion command (e.g., the \includegraphics command's bb option). There are several ways to calculate the BoundingBox parameters (a) Use Ghostview/GSview to display the PostScript graphic. As the pointer is moved around the graphic, the pointer's coordinates (with respect to the lower-left corner of the page) are displayed. To determine the BoundingBox parameters, record the pointer coordinates at the lower-left corner of the graphic and the upper-right corner of the graphic. (b) Print out a copy of the PostScript graphics and measure the horizontal and vertical distances (in inches) from the lower-left corner of the paper to the lower-left corner of the graphics. Multiply these measurements by 72 to get the BoundingBox's lower-left coordinates. Likewise, measure the distances from the lower-left corner of the paper to the upper-right corner of the graphics to get the BoundingBox's upper-right coordinates.
(c) The bbfig script uses a PostScript printer to calculate the BoundingBox.
bbfig adds some PostScript commands to the beginning of the PostScript
file and sends it to the printer. At the printer, the added PostScript
commands calculate the BoundingBox of the original PostScript file, printing the
BoundingBox coordinates superimposed on the PostScript graphic. ---------------- end excerpt ----------------- 2000-Mar-29 9:38am furnstahl.1@osu.edu | |
Here's a new way: If you have Ghostscript 6.0 (or later), the command:
gs -sDEVICE=bbox -dNOPAUSE -dBATCH file.pswill print the bounding box information for file.ps (and then exit gs). I have written a perl script that will automatically find the bounding box and correct the postscript file (or add the info if there is none). The script is </~ntg/scripts/bbox_add.pl>Be sure to make it executable: chmod +x bbox_add.plTo see the options and the defaults, bbox_add.pl --help 2001-Sep-07 5:01pm furnstahl.1@osu.edu | |
| [Append to This Answer] | |
| 2001-Sep-07 5:01pm |
| Previous: |
|
| Next: |
|
| ||||||||||