3.3 Converting PS ﬁles to EPS
Single-page PostScript ﬁles without any improper commands can be converted to
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 ﬁles unless the PS ﬁles are free of forbidden operators.
1. The most convenient option is to use the ps2epsi utility distributed with
Ghostscript (seeSection6.1 on Page 17), which reads the PostScript ﬁle, cal-
culates the BoundingBox parameters, and creates an
ﬁle (complete with
aBoundingBox) which contains the PostScript graphics.
The resulting ﬁle
ﬁle is in
format, which means it contains an Inter-
change (low-resolution bitmapped) preview at the beginning of the ﬁle. Since
-encoded, it does not cause theSection4.1bufsize errors.
preview increases the ﬁle size.
2. Another method of having ghostscript calculate the BoundingBox parameters
is to use the epstool utility, available for Unix,
,Windows, and OS/2 from
For example, the command
epstool --copy --bbox file1.eps file2.eps
analyzes the contents of file1.eps to determine the correct BoundingBoxand
then copies the contents of file1.eps with the calculated BoundingBox into
The epstool utility can also be used to add
ﬁle, or extract bitmap previews from an
3. Alternatively, the BoundingBox parameters can be calculated and manually
inserted in the PostScript ﬁle’s BoundingBox line or speciﬁed in the graphics-
insertion command (e.g., the \includegraphics command’sbb 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 Bound-
ingBoxparameters, 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’slower-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 addssome PostScript commands to the beginning of the PostScript
ﬁle and sends it to the printer. At the printer, the added PostScript com-
mands calculate the BoundingBox of the original PostScript ﬁle, printing
the BoundingBox coordinates superimposed on the PostScript graphic.
The bbfig script is available from
3.4 Fixing Non-standard EPS ﬁles
Some applications (such as Mathematica and FrameMaker) produce non-standard
ﬁles which cannot be used in other programs such as LAT
X. Some of these ap-
plications have developed their own “improved” ﬂavor of PostScript with additional
features, while other applications use poor PostScript programming. Often these
can be easily ﬁxed by scripts provided byeither the software com-
panies themselves or by PostScript-savvy users. Check the software manufacturer’s
web page or search USENET groups associated with the software.
4 How EPS Files are Used by L
When processing a dvips-style document, the
ﬁles are used by both L
ﬁle for the BoundingBoxline, which tells L
space to reserve for the graphic.
converterthen reads the
ﬁle and inserts the graphics in the
This has the following ramiﬁcations
• If the BoundingBoxparametersare speciﬁedin the graphics-insertioncommand
(e.g., the bb option of \includegraphics is used) then L
Xnever even reads
ﬁle. In fact, the
ﬁle does not even need to exist when L
• Since T
ﬁlesandcannot spawn other programs,L
cannot read the BoundingBox information from compressed or non-
ics ﬁles. In these cases, the BoundingBox parameters must be speciﬁed in the
graphics-insertion command (e.g., in the bb option of the \includegraphics
command) or stored in a non-compressed text ﬁle (seeSection14on Page 42).
graphics are not included in the
ﬁle. Since the
be present when the
ﬁle is converted to
ﬁles must accompany
ﬁles whenever they are moved.
graphics may not appear in some
viewers. To help the user with
placement of the graphics,these
in which the graphics will be inserted.
4.1 Line Buﬀer Overﬂow
ﬁles one line at a time, putting each line in its line buﬀer, which
is often about 3000 characters long. If any of the lines of the
ﬁle is longer than
the line buﬀer, the following error is displayed
Unable to read an entire line--bufsize=3000.
Please ask a wizard to enlarge me.
rarely have lines longerthan 3000 characters, there are two possible causes
of such an error
1. The EPS ﬁle contains a long binary preview.
Some applications place a binary preview of the graphics at the beginning of
ﬁle. This allows applications (such as
viewers) to display the
graphics even though the application cannot interpret PostScript. Currently,
relatively few T
X-related applications use such previews.
If the binary preview is smaller than the line buﬀer, the \includegraphics
command skips over the preview
. However, the overfull bufsize error occurs
if the binary preview is larger than the line buﬀer. There are a couple work-
arounds for this problem
(a) If the preview won’t be used, the problem canbeavoided byeither deleting
it with a text editoror bypreventing the originalgraphicsapplicationfrom
creating the preview.
(b) Since LAT
ﬁle to only obtain the BoundingBox parame-
X does not read the
ﬁle if the BoundingBox parameters
are provided by the graphics-insertion command (e.g., the bb option to
2. The ﬁle’s end-of-line characters are corrupted by an improper trans-
The following problem does not occur with most recent T
versions of T
Xare smart enough to identify all end-of-line characters.
Diﬀerent platforms use diﬀerent end-of-line characters: Unix uses a line feed
character (^J), Macintosh uses a carriage return (^M), while
uses a carriage return and line feed pair (^M^J). For example, if an
transferred in binarymode from a Macintosh to a Unixmachine, the Unix T
doesn’t see any ^J end-of-line characters and thus thinks the entire ﬁle is one
big line, overﬁlling the line buﬀer.
ﬁle has no binarysections (e.g., no binary preview and no embedded
graphics) this problem can be avoided by transferring the
ﬁle in text
ﬁles with binary sections must be transferred with binary
mode, since the text mode transfer may corrupt the binary section. Since this
binary transfer does not translate the end-of-line characters, the BoundingBox
information must be provided by the graphics-insertion command (e.g., the bb
option to \includegraphics).
5 PDF Graphics
As mentioned earlier, pdfT
Xcan directly import the
Post graphic formats. This section provides a short description of these formats.
The commands for inserting these graphics into pdfLAT
Xare described inSection7
on Page 22.
is a compression standard authored by Joint Photographic Experts Group
Note that \psfig and other obsolete graphics commands did not have the ability to skip over
format is a compression standard for bitmap graphics which uses a lossy
compression scheme. In particular, its compression does not preserve lines and sharp
edges, making it poorly suited for line drawings and or graphics with sharp features.
For many years the
format was the standard for compressed bitmaps for icons
and other line drawings, since its lossless
compression does not distort sharp
edges. Unisys’s enforcement of its
patent coupled with some
limitations (such a limit of 256 colors) spurred the development of the Portable
NetworkGraphics (PNG) format by a group eventuallycalled the
Like GIF, PNG uses lossless compression which is suitable for line drawings. While
can be used on any bitmap,
’s lossy compression is often better than
for photographs and other bitmaps without sharp edges (where “better” means
producing smaller ﬁles without distortion noticeable by the naked eye).
Adobe’s Portable Document t Format t (
) shares many similarities to its Adobe
sibling PostScript. Like PostScript,
can contain text, vector drawings, and
bitmap drawings. A
ﬁle can contain an entire document orjust a single drawing
is not only the primary output format of pdfT
also is the most
common method for importing vector graphics into pdfT
X. Many graphics pro-
grams allow their graphics output to be directly saved in
output can instead output
vector graphics which can be eas-
ily converted to
vector graphics by the epstopdf conversion program available
as a Windows executable or as a perl script for use on other platforms
such as Unix/Linux or MacOS X
MetaPost is a graphics language written by John Hobby that is based on Donald
Knuth’s metafont, but with the added capability of outputting PostScript. Infor-
mation about MetaPost is available from
and is documented in .
MetaPost can be used inn dvips-style LAT
Xdocuments and also can be used
Lossy compression means that the compression process loses data. That is, decompresssing a
lossy-compressedbitmapdoes not produce the original bitmap. Conversely, no data is lost duringa
lossless compression, so decompressing a lossless-compressed bitmap produces the original bitmap.
Xactually uses ConTeXt code by Hans Hagen to convert MetaPost graphics into
on-the-ﬂy, however this is transparent to users.
The following procedure uses the pstoedit utility along with MetaPost (mpost)
to convert an
ﬁle named graphic.eps into a MetaPost ﬁle name graphic.mps
pstoedit -f mpost graphic.eps graphic.mp
rename graphic.1 graphic.mps
Scott Pakin’s purifyeps utility is able to convert many (but not all)
“puriﬁed” version that can be read by both LAT
You need all of the following in order to run purifyeps:
PurifyEPS Available fromCTAN/support/purifyeps/ where CTAN/ should be re-
placed by any of the
sites listed on page3.
Perl Available fromhttp://www.cpan.org
pstoedit Available fromhttp://www.pstoedit.net/pstoedit
mpost from a LAT
Xdistribution that includes MetaPost.
6 Graphics Software
Ghostscript is a PostScript/
interpreter which runs on most platforms and is
distributed for free
. This allows PostScript,
ﬁles to be displayed
on the screen and printed to both Postscript and non-PostScript printers. AFPL
Ghostscript is available from the Ghostscript home page
These sites contains pre-compiled Windows/
/OS/2 and Macintosh executables,
along with ready-to-compile source code for Unix/
. Also available are graphical
interfaces (such as GSview, Ghostview, GV, etc) for Ghostscript which makes the
viewing of PostScript much easier.
6.2 Graphics-Conversion Programs
The following freeware and shareware programs convert between graphics format.
In dvips-style documents, these programs can convert non-
Xdocuments, these program can convert graphics to one of the supported
). Some of the programs allow command-line conver-
sion which makes it possible to convert the graphics on-the-ﬂy (seeSection14.2 on
Although AFPL Ghostscript (formerly known as Aladdin Ghostscript) is distributed for free,
it is not in the public domain. It is copyrighted and comes with certain limitations such as no
commercial distribution. When versions of Aladdin Ghostscript become approximately one year
old, Aladdinreleasesthemas “GNU Ghostscript” whose use is governed by the less-restrictive GNU
ImageMagick is a free open-source software suite to create, edit, and compose
bitmap images. It can read, convert and write images in a large variety of
formats. Images can be cropped, colors can be changed, various eﬀects can be
applied, images can be rotated and combined, and text, lines, polygons, ellipses
and Bezier curves can be added to images and stretched and rotated.
For example, when ImageMagick’s convert is on the operating system path,
the following command
convert file.jpg file.eps
version of file.jpg in file.eps.
Multiple ﬁles can be converted with the wildcard
convert *.gif images.png
versions of all the
ﬁles in the current directory and stores
Saving the resulting
ﬁles with the same base ﬁlename as the original
ﬁles is more involved since it requires writing a shell script or Windows batch
ImageMagickrunson allmajoroperating systemsand Binariesand information
can be downloaded from
The ImageMagick interface periodically changes, causing incompatibility with
code that uses ImageMagick. As a result, the GraphicsMagick project was
started in November 2002 as a fork from ImageMagick 5.5.2, with the goal of
providing a set of graphics-conversion utilities with a stable interface and an
emphasis on ﬁxing bugs over adding new features.
GraphicsMagick runs on Unix/Linux, Cygwin, MacOS X, and Windows. Bi-
naries and source code can be downloaded from
NetPBM is a free open-source version of the now-unsupported PBMPLUS package.
NetPBM is a toolkit for manipulation of graphic images, including conversion of
images between a variety of diﬀerent formats. There are over220 separate tools
in the package includingconvertersforabout 100graphicsformats. NetPBM uses
the commandline and doesn’t have a graphical interface.
Most Linux distributions and the Cygwin Project include NetPBM packages.
Binary distributions of NetPBM for Windows, MacOS X, and other operating
systems can be downloaded from
Irfanview is an excellent, easy-to-install graphic viewer for Windows that is
compact and fast. Irfanview supports viewing and converting between a wide
variety of ﬁle formats, and provides basic image editing (such as cropping,
resampling, color/brightness adjustments, etc). Irfanview supports both GUI
and commandline operation, including batch mode.
For example, when Irfanview’s executable i
view32.exe is on the Windows
path, the following command
i_view32 *.gif /convert=*.png
versions of all the
ﬁles in the current directory, storing them
in ﬁles with .png extensions and the same base name as the original
Irfanview can be downloaded from
Irfanview is freeware for personal, academic, and non-proﬁt users. Commercial
users are asked to donate a $12 registration fee.
Graphic Converter is $30 shareware for Macintosh which reads about 190
graphic formats and exports about 75 formats. For information, see
WMF2EPS is a $20 shareware
conversion program which runs on
Windows. It is available from
where CTAN/ should be replaced by any of the
sites listed on page3.
The software can also be downloaded from the WMF2EPS homepage
Thehomepage alsoincludesotherinformation,including linksto Adobe-compatible
printer drivers (which is required for WMF2EPS).
is shareware ($25 for non-commercial use, $50 forcommercial use) which
converts bitmap graphics (
, etc) into PostScript and other
isavailable forWindows, OS/2, Linux, Unix, Macintosh,
and BeOS. More information is available at
xv is an interactive image manipulation program for the X Window System.
While it has graphics-conversion capability, xv was designed for image manip-
ulation program and thus is not tailored for graphics conversion (for example,
it does not provide command-line capabilities so graphics must be one-by-one.
xv is $25 shareware for non-commercial use, with the $25 registration manda-
tory for commercial use. More information is available from
Image Manipulation Program) is a freely available image ma-
nipulation program which duplicates much of the functionality of PhotoShop.
is available for Unix/Linux, Windows, and MacOSX. More information
is available at
6.3 Level 2 EPS Wrappers
Level 2 PostScript supports several compression schemes, including DCT (used in
(used in many
ﬁles). Additionally, this binary data can
Hex (which produces
ﬁles which are
125% and 200%, respectively, of the original binary size). The fact that Level-2
supports these compression schemes allows a Level-2
ﬁle to be constructed as a
wrapper around a
ﬁle. This produces better quality and smaller
ﬁles thanconverting the graphicstoconventional
.If one has a Level 2PostScript
printer, it is better to use the following wrapper programs instead of the conversion
programs listed above. Since the resulting PostScript ﬁles can only be printed on
Level 2 printers, the documents are less portable.
Note that, by default, dvips strips the comment lines (those lines which begin
with %%) from anyincluded
85-encoded level-2 graphicscan
have lines beginning with %%, users including
use the dvips -K0 (K followed by a zero) option to prevent dvips from stripping
comment lines. Note
Hex level-2 encoding does not have this problem.
graphic can be converted to level 2 PostScript by the C program
jpeg2ps, which can be compiled Unix,
,and other systems. jpeg2ps is
where CTAN/ should be replaced by any of the
sites listed on page3.
jpeg2ps supports three types of level-2 encoding:
85 (default), 8-bit
binary (using jpeg2ps -b), or 7-bit
Hex (using jpeg2ps -h).
Documents you may be interested
Documents you may be interested