bmp2eps - converts various bitmap formats to EPS, PDF or PNG.


bmp2eps [-adehlnpqrsuvxzVXZ] [-24] [-pdf] [input [output]]


bmp2eps converts various bitmap formats to Encapsulated PostScript, PDF or PNG in a lossless fashion, as far as possible. Baseline JPEGs (or extended sequential DCT JPEGs) simply use the DCT filter, other formats are LZW (if enabled), Flate (if enabled), RLE or no compression. Bilevel data uses CCITT encoding if RLE requested. PNG and JPEG output can be emitted Base64 encoded and wrapped in an HTML (or SVG) structure.</p>

It can also combine multiple images into a single PDF or PS file.

Attempts are made to make the output relatively compact. Bit-depth is reduced if possible without any loss of quality, and alpha channels which contain no information are removed. Multiple attempts to compress using zlib and predictors are made, in an attempt to find something more optimal than the default.

By default the resulting binary data are ASCII85 encoded to produce a 7-bit clean EPS file, with options to produce PDF and keep the data binary. The PDF option does not support RLE encoding of 24 bit data.

If the executable is named bmp2pdf, then the default output is PDF. If named bmp2png, then PNG.

Alpha channels can be preserved if the output is PNG or PDF (for which they are converted to soft masks). For PostScript output, they can be converted to Type 3 single bit masks. In all cases they can be stripped.

PNG is a valid output if compiled with zlib and if the input is not JPEG. If compiled with libpng, PNGs will be read with libpng, else an internal reader is used. If compiled without zlib, only PNGs which lack an alpha channel can be read, for these can easily be passed unchanged to EPS or PDF output.

Output is to stdout unless otherwise specified, errors and information to stderr.

The following input formats are automatically recognised and supported.


MS Windows and OS/2 bitmap. Depths of 1, 4, 8, 24 and 32 bits per pixel supported. Compressed bitmaps supported at depths of 4 and 8.


GIF87 and GIF89 containing a single image. Transparency supported.


Colour or greyscale baseline or extended sequential DCT JPEGs. Not progressive JPEGs.


Binary or ASCII data.


Up to 8 bit greyscale.


Fully supported.


Something which is either a PBM, PGM or PPM file (q.v.)


24 bit colour.


Greyscale, paletted or full colour, with or without RLE compression. Left to right only.

PNGs with 16 bits per channel are reduced to 8 bits per channel.

The 24 bit formats have the number of colours used counted, and are output in paletted form if the unique colour count is 256 or fewer.

A single transparent colour is supported for GIFs. Transparency results in level 3 PostScript, and PDF 1.3.

The alpha channel in PNGs can be retained for PDFs. For EPS output it needs to be reduced to a single-bit mask. In either case it can also be stripped. If it contains no information, it will be stripped.



(implies -p) use ISO A series paper size


ignore background colour in image


use specified colour as background colour


use given bounding box. Lower left corner assumed to be zero if not given. If only urx given, ury calculated from image size


add Distiller parameters to discourage Distiller from resampling or from using DCT on non JPEG images


use dpi value from file, or from command line. Without this option, any dpi value in a JPEG or PNG file is simply ignored


(implies -p) expand to fill page


fast: use faster, but poorer, flate compression


use CCITT Group 3 1D encoding on bilevel images. Probably not useful.


use CCITT Group 4 2D encoding on bilevel images.


show version and help text and exit


produce an html image with inline base64 data


use internal PNG reader, even if compiled with libpng support


produce landscape output


use no compression on output (no affect on JPEGs)


perform lossy reduction to d bits per channel (no affect on JPEGs)

-o file

alternative to naming output as last file


overwrite input file with output. Implies -png, and input must be PNG.


fit to page and centre. If output was EPS, produce PostScript (i.e. include showpage and setpagedevice). Uses compiled-in default paper size (probably A4) unless another size is specified


produce PDF. Default if called bmp2pdf.


produce PNG. Must use FLATE compression, cannot convert JPEG input. Default if called bmp2png.


select PNG predictors to try with flate/LZW output and 24 bit colour or 8 bit greyscale images. Set n to the sum of the predictors wanted, where sub is 1, up is 2, av is 4 and paeth is 8. -P=0 disables prediction, -P=15 is the default (try all predictors).


do not decompress PNGs. Implies -i. Default if not compiled with libz.


produce RTL output suitable for an HP DJ1055 and HP Z5600 (and probably other similar printers). Transparency will be removed, One-bit images are sent uncompressed. Supports 24 bit RGB images, and paletted or greyscale images with depths of 2, 4 or 8 bits. Tries both seedrow and packbits compression. If -n given, no compression attempted other than duplicate row removal. The -D flag should be given, and should probably be a factor of 600. -q surpress informational messages


RLE compress data (ignored for JPEGs). Treated as -G4 for bilevel images.


smooth output by setting interpolate true. Greatly increases time to interpret PostScript/PDF for little effect.


produce an svg image with inline base64 data


ignore any transparency information in input (default is to respect transparency if possible)


make white transparent (short for -t=255,255,255)


make given colour transparent (base 10)


(implies -p) use US letter paper size


be verbose (more vs for more verbosity)


list supported file types and exit


write palette in hex, not base 85


write all data in hex, not base 85


Flate compress output, thus producing level 3 EPS (ignored for JPEGs). This will use zlib even if compiled with zopfli support. If compiled with zopfli support, zopfli will be the default.


LZW compress output, thus producing level 2 EPS (ignored for JPEGs)


add code to protect PostScript Level 3 operations from Level 2 interpreters. Unlikely to be needed in the 21st century


keep 24 bit images as 24 bit, even if they use fewer than 257 colours


keep output 7-bit (default for EPS/PS, ignored for PNG)


use 8-bit output (default for PDF)


try harder with flate compression, but with greatly increased runtime. May usefully be repeated up to -999.

If no file name is specified, input will be read from stdin.

The r,g,b colour specifications are in decimal, but the format rrggbb in hex is also accepted, as is g (decimal) for greyscale.

In the author’s opinion, 8-bit PostScript is bad.

A utility such as jpegtran can be used to convert most non-baseline JPEGs to baseline, and to do other useful lossless transforms. Utilities such as pngtopnm (if this version was compiled without PNG support) and tifftopnm assist in dealing with other input file types.


To print a gif file to a PostScript printer

bmp2eps -p in.gif | lpr

The same, but landscape orientation and expanded to fill the page

bmp2eps -plx in.gif | lpr

To convert a bmp file to EPS for use with, for example, xfig or LaTeX

bmp2eps in.bmp > out.eps

The same for a progressively-encoded colour jpeg with the output being greyscale

jpegtran -grey -optimise in.jpeg | bmp2eps > out.eps

To produce a single page PDF file from a jpeg

bmp2eps -pdf in.jpeg > out.pdf

to produce a multiple page PDF from several images

bmp2eps -pdf fig1.png fig2.bmp fig3.jpg out.pdf


bmp2pdf fig1.png fig2.bmp fig3.jpg out.pdf

ditto, but faster (at the expense of less compression)

bmp2pdf -Rf fig1.png fig2.bmp fig3.jpg out.pdf

to shrink a directory full of PNG files in place

bmp2eps -O -99 *png

(Do make sure a backup of the files exists first, just in case...)


Absolutely none. The author makes no claim that this code is fit for any purpose: use it only if you are satisfied with it. The author’s employer, the University of Cambridge, has absolutely nothing to do with this project. This version is distributed under version 2 of the GPL.


Please report to mjr19@ (Cambridge University domain).


jpegtran(1), pngtopnm(1), tifftopnm(1).


PostScript, PDF and Distiller are trademarks of Adobe Systems Incorporated. OS/2 is a trademark of IBM. Other trademarks are the property of their respective owners.