EPS (Encapsulated PostScript)
| Full name | Encapsulated PostScript |
|---|---|
| Extensions | .eps, .epsf, .epsi (with an ASCII preview) |
| MIME type | application/postscript (also seen: image/x-eps, application/eps) |
| Type | vector graphic (a one-page PostScript program), can embed raster images |
| Starts with | 25 21 50 53 2D 41 64 6F 62 65 (%!PS-Adobe-3.0 EPSF-3.0) or C5 D0 D3 C6 (binary header with a TIFF or WMF preview) |
| Specification | Adobe Technical Note 5002, Encapsulated PostScript File Format Specification 3.0, with the DSC Specification 3.0 (PDF) |
| Maintained by | Adobe (no longer developed) |
| License | open specification |
An EPS file is a PostScript program that draws one picture and says how big it is. The %%BoundingBox comment gives the area the drawing covers, so a page layout program, word processor or LaTeX can place, scale and crop the graphic without understanding the PostScript inside. Programs that can’t run PostScript show an embedded low-resolution preview instead, or a gray box.
EPS was the standard exchange format for logos, illustrations and charts in print workflows. It’s still requested by some print shops and stock-image sites and produced by Illustrator, CorelDRAW, Inkscape, matplotlib, R and gnuplot. For new work, PDF does the same job better, and SVG is the vector format for the web.
When to use EPS#
- Use when a printer, publisher or stock agency asks for EPS.
- Use with
latex+dvips(the classic TeX route), which includes graphics only as EPS. - Avoid for new files: use PDF for print and SVG for the web. Both support transparency, which EPS doesn’t.
- Avoid in Microsoft Office: Office no longer inserts EPS files (the filter was turned off in 2017 for security reasons).
- Avoid opening EPS files from unknown sources in programs that run them without a sandbox: EPS is PostScript code.
File structure#
An EPS file is a PostScript file with extra rules:
- exactly one page;
- a
%%BoundingBoxcomment in the header; - no operators that change the device or global state:
setpagedevice,initgraphics,initmatrix,initclip,erasepage,copypage,exitserverand similar are not allowed; - leave the operand stack and dictionary stack as it found them.
showpageis allowed: the importing program redefines it.
%!PS-Adobe-3.0 EPSF-3.0
%%Creator: my program
%%Title: logo.eps
%%BoundingBox: 0 0 200 100
%%HiResBoundingBox: 0.000000 0.000000 200.000000 100.000000
%%LanguageLevel: 2
%%Pages: 1
%%EndComments
%%Page: 1 1
0.2 0.4 0.8 setrgbcolor
10 10 180 80 rectfill
1 setgray
/Helvetica-Bold findfont 36 scalefont setfont
30 38 moveto (LOGO) show
showpage
%%EOF
Bounding box#
%%BoundingBox: llx lly urx ury gives the lower-left and upper-right corners in integer PostScript points (1/72 inch). %%HiResBoundingBox gives the same with decimals. The drawing doesn’t have to start at 0,0: an EPS file cut out of a page often has a box like 72 500 300 720.
A wrong bounding box is the most common EPS problem: the graphic is clipped or surrounded by white space. Ghostscript computes the real box:
gs -dNOPAUSE -dBATCH -dSAFER -q -sDEVICE=bbox in.eps
# %%BoundingBox: 10 10 190 90
# %%HiResBoundingBox: 10.000000 10.000000 190.000000 90.000000
Previews#
Programs that can’t render PostScript show a preview. There are three kinds:
| Preview | Where it is | Used by |
|---|---|---|
| TIFF or WMF in a binary header (“DOS EPS”) | binary header before the PostScript | Windows programs, most common |
| EPSI | hex bitmap in %%BeginPreview … %%EndPreview comments |
Unix programs; plain text |
| PICT | resource fork | classic Mac OS only; lost when the file is copied to another system |
Binary header (DOS EPS)#
A file with a TIFF or WMF preview starts with a 30-byte header. All numbers are little-endian:
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | magic C5 D0 D3 C6 |
| 4 | 4 | offset of the PostScript section |
| 8 | 4 | length of the PostScript section |
| 12 | 4 | offset of the WMF preview (0 if none) |
| 16 | 4 | length of the WMF preview |
| 20 | 4 | offset of the TIFF preview (0 if none) |
| 24 | 4 | length of the TIFF preview |
| 28 | 2 | checksum of bytes 0-27, or FF FF to ignore |
C5 D0 D3 C6 magic
1E 00 00 00 PostScript starts at offset 30
A4 2B 00 00 PostScript length 11172
00 00 00 00 00 00 00 00 no WMF preview
C2 2B 00 00 9C 40 00 00 TIFF preview at 11202, length 16540
FF FF no checksum
25 21 50 53 2D 41 64 6F %!PS-Ado...
To read the PostScript, seek to the offset and read the given length. Tools that expect %!PS at the start fail on such files; ps2eps, Ghostscript and most libraries handle both.
EPSI preview#
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 200 100
%%EndComments
%%BeginPreview: 200 100 1 100
% FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
% ...
%%EndPreview
The numbers after %%BeginPreview: are width, height, bits per pixel and the number of comment lines that follow. Ghostscript’s ps2epsi script adds such a preview.
Converting EPS#
# EPS to PDF, page cropped to the bounding box (TeX Live / MiKTeX)
epstopdf in.eps
gs -dNOPAUSE -dBATCH -dSAFER -dEPSCrop -sDEVICE=pdfwrite -sOutputFile=out.pdf in.eps
# EPS to PNG at 300 dpi with a transparent background
gs -dNOPAUSE -dBATCH -dSAFER -dEPSCrop -sDEVICE=pngalpha -r300 -sOutputFile=out.png in.eps
# EPS to SVG
inkscape in.eps --export-filename=out.svg
# PDF page to EPS
pdftops -eps -f 1 -l 1 in.pdf out.eps # Poppler
gs -dNOPAUSE -dBATCH -dSAFER -sDEVICE=eps2write -sOutputFile=out.eps in.pdf
Without -dEPSCrop, Ghostscript places the graphic on a full default page (Letter or A4) at its bounding box position.
Specifications and documentation#
- Document Structuring Conventions Specification 3.0 (Adobe Technical Note 5001, PDF): the comments EPS relies on. The EPSF 3.0 rules are in Adobe Technical Note 5002.
- PostScript Language Reference, Third Edition (Adobe, PDF)
- Ghostscript: EPS options (
-dEPSCrop,-dEPSFitPage) and ps2epsi - PRONOM record for EPS 3.0 (UK National Archives)
- Encapsulated PostScript on Wikipedia
Software that opens EPS files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; opens .eps when Ghostscript is installed | |||
| Adobe Illustrator | ✓ | ✓ | view, edit, create, convert | commercial; the most common EPS editor | ||
| Inkscape | ✓ | ✓ | ✓ | view, edit, create, convert | free, open source; imports EPS through Ghostscript | |
| Affinity | ✓ | ✓ | view, edit, create, convert | imports and exports EPS | ||
| CorelDRAW | ✓ | ✓ | view, edit, create, convert | commercial | ||
| GIMP | ✓ | ✓ | ✓ | view, convert | rasterizes EPS through Ghostscript | |
| LibreOffice | ✓ | ✓ | ✓ | view, convert | free; Draw imports EPS, shows the preview in documents | |
| Ghostscript | ✓ | ✓ | ✓ | view, convert | interpreter; gs, ps2pdf, eps2write; AGPL or commercial | |
| Okular | ✓ | view | free, open source, through libspectre | |||
| Evince | ✓ | view | GNOME document viewer | |||
| IrfanView | ✓ | view, convert | free for non-commercial use; needs Ghostscript and the PostScript plugin | |||
| XnView MP | ✓ | ✓ | ✓ | view, convert | free for private use; uses Ghostscript | |
| ImageMagick | ✓ | ✓ | ✓ | convert | command line; reads EPS through Ghostscript |
macOS Preview stopped opening EPS in macOS 13. On a current Mac use Illustrator, Affinity or Inkscape, or convert with Ghostscript (brew install ghostscript).
Libraries#
Open-source libraries that render, inspect and write EPS. See all EPS libraries for a comparison.
| C/C++ | cairo, Ghostscript, libspectre |
|---|---|
| C# | Ghostscript.NET, Magick.NET |
| Java | xmlgraphics-commons |
| Go | canvas, gonum/plot |
| Python | Matplotlib, Pillow, pycairo |
| Ruby | MiniMagick |
| Rust | cairo-rs |
| PHP | Imagick |
Related formats#
- PostScript: EPS is a restricted, single-page PostScript file
- PDF: the modern replacement for EPS in print workflows, with transparency
- SVG: vector graphics for the web
- TIFF: the usual preview image inside a binary EPS header