bmp2eps

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
WARRANTY
BUGS
SEE ALSO
TRADEMARKS

NAME

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

SYNOPSIS

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

DESCRIPTION

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.

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.

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.

BMP

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.

GIF

GIF87 and GIF89 containing a single image. Transparency supported.

JPEG

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

PBM

Binary or ASCII data.

PGM

Up to 8 bit greyscale.

PNG

Fully supported.

PNM

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

PPM

24 bit colour.

TGA

Greyscale, paletted or full colour, with or without RLE compression. Left to right only, and the alpha channel is ignored.

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.

OPTIONS

−a(0-6)

(implies -p) use ISO A series paper size

−b=

ignore background colour in image

−b=r,g,b

use specified colour as background colour

−B=urx[,ury]
−B=llx,lly,urx,ury

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

−d

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

−D[=dpi]

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

−e

(implies -p) expand to fill page

−G3

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

−G4

use CCITT Group 4 2D encoding on bilevel images.

−h

show version and help text and exit

−html

produce an html image with inline base64 data

−i

use internal PNG reader, even if compiled with libpng support

−l

produce landscape output

−n

use no compression on output (no affect on JPEGs)

−p

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

−pdf

produce PDF. Implies -z8

−png

produce PNG. Must use FLATE compression, cannot convert JPEG input

−P=n

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).

−R

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

−rtl

produce RTL output suitable for an HP DJ1055. 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

−r

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

−s

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

−svg

produce an svg image with inline base64 data

−t

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

−t=

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

−t=r,g,b

make given colour transparent (base 10)

−u

(implies -p) use US letter paper size

−v

be verbose (more vs for more verbosity)

−V

list supported file types and exit

−x

write palette in hex, not base 85

−X

write all data in hex, not base 85

−z

Flate compress output, thus producing level 3 EPS (ignored for JPEGs)

−Z

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

−2

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

−24

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

−7

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

−8

use 8-bit output (default for PDF)

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

If called as something ending in the string 2pdf then -pdf will be assumed.

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.

EXAMPLES

To print a gif file to a PostScript level 2 printer

bmp2eps -pZ in.gif | lpr

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

bmp2eps -plxZ 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

WARRANTY

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.

BUGS

Please report to mjr19@ (obvious University domain).

SEE ALSO

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

TRADEMARKS

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.