PBMPLUS and NETPBM image tools

Large sections of this document are lifted from the README files in the PBMPLUS and NETPBM distribution. This is the only way I could make this document useful.

Included in this document is

The Extended Portable Bitmap Toolkit

PBMPLUS is a toolkit for converting various image formats to and from portable formats, and therefore to and from each other. The idea is, if you want to convert among N image formats, you only need 2*N conversion filters, instead of the N^2 you would need if you wrote each one separately.

In addition to the converters, the package includes some simple tools for manipulating the portable formats.

The convention of the tools in the package are to accept a filename on the command line or to read standard input if a filename is not given. Their output is almost alway on standard output. This means that you should always direct the output to a file or to another command.

This philosophy allows incredible manipulations to be accomplished in one long pipeline of Unix commands. Such a pipeline removes the need for managing temporary files or, in most cases, doesn't even require disk space sufficient to hold the intermediate images.

Pieces of the package

The package is broken up into four parts. First is PBM, for bitmaps (1 bit per pixel). Then there is PGM, for grayscale images. Next is PPM, for full-color images. Last, there is PNM, which does content-independent manipulations on any of the three internal formats, and also handles external formats that have multiple types.

The parts are upwards compatible: PGM reads both PGM and PBM files and writes PGM; PPM reads all three and writes PPM; and PNM reads all three and writes, usually, the same type as it read. Whenever PNM makes an exception and "promotes" a file to a higher format, it lets you know.

Support for the package

If you have access to Usenet, there's a newsgroup called alt.graphics.pixutils which is specifically for discussion of image conversion and editing packages such as PBMPLUS. Posting stuff there is even better than mailing it to me, since it lets other people help out with the answers.

How to find the right converter

Some people get confused by all the different names. If you want to convert a pbm file to a Sun raster file, is it pbmtorast, pgmtorast, ppmtorast, or pnmtorast? In this case some of the confusion might be because previous versions of the package did in fact have both pbmtorast and ppmtorast. But mostly it's just too many different things to hold in your short term memory. Fine, so don't even try to remember what's what. That's what computers are for. Unix, at least BSD Unix, has this great indexing feature on the "man" program. You say "man -k " and it gives you all the one-line descriptions with that keyword in them. All the PBMPLUS man pages have nice useful one-line descriptions, that mention all the relevant keywords. Try it, you'll like it.

The NETPBM toolkit

Netpbm is a toolkit for conversion of images between a variety of different formats, as well as to allow a few basic image operations. The package is intended to be portable to many platforms. It has been tested under UNIX (BSD and SYSV, e.g. SGI, Sun4, Sun386i, DEC and Apollo DN 3500), VMS and Amiga OS. There are also compiler directives in it for MS-DOS.

Netpbm is based on the widely spread Pbmplus package (release: 10 Dec 91). On top of that, a lot of improvements and additions have been made. After the latest release of Pbmplus, a lot of additional filters have been circulating on the net. The aim of Netpbm was, to collect these and to turn them into a package. This work has been performed by a group of program- mers all over the world. If *you* have some code to add, please contact us, and we will incorporate it. There is a mailing list for discussions about Netpbm. You post a message to the list by writing to "netpbm@fysik4.kth.se". If you want to be on the list, send a mail with the message "subscribe netpbm" to "majordomo@fysik4.kth.se". If you want to report a bug, please send your report to netpbm@fysik4.kth.se, and to the author of Pbmplus, jef@netcom.com.

The code in NetPBM is merely a collection of code from various sources around the world. Not all of the new code parts follow the high standard of programming of Pbmplus. We have tried to make the code portable to as many systems as possible, but we haven't cleaned up all routines. We hope that this will help the many users of Pbmplus to upgrade their code all in one piece, instead of having to hunt down different code fragments at different sites around the world. We also hope, that our effort will help the author of Pbmplus, Jef Poskanzer, to make a new official release soon.

Where to get the tools

For the latest release of Netpbm, you can look at the following sites: You'll also find a mirror site at the BBS:

The tools that you are most likely to need

Most of the time, you will only be interested in a small set of image formats and a small set of image manipulations.

Typically, you will want to convert your image into a PBMPLUS format, do some small translations on it, and convert it to an output format. The format you select for output depends on the tradeoffs inherent in the different forms of image compression.

The following NetPBM/PBMPLUS tools (and the Other related software) will probably get you through most things.

giftoppm
convert GIF to portable pixmap
ppmtogif
convert portable pixmap to GIF
ppmquant
quantize colors down to a specified number
pnmtops
convert portable anymap to PostScript
pnmcut
select a rectangular region from a portable anymap
pnmscale
scale a portable anymap
ppmdither
ordered dither for color images
pbmtext
render text into a bitmap
pnmcat
concatenate portable anymaps
pnmindex
script to build a visual index of a bunch of anymaps
pnmgamma
perform gamma correction on a portable anymap
ppmtopgm
convert portable pixmap to portable graymap

The full list of tools

atktopbm
convert Andrew Toolkit raster object to portable bitmap
brushtopbm
convert Xerox doodle brushes to portable bitmap
cmuwmtopbm
convert CMU window manager format to portable bitmap
g3topbm
convert Group 3 FAX to portable bitmap
icontopbm
convert Sun icon to portable bitmap
gemtopbm
convert GEM .img format to portable bitmap
macptopbm
convert MacPaint to portable bitmap
mgrtopbm
convert MGR format to portable bitmap
pi3topbm
convert Atari Degas .pi3 to portable bitmap
xbmtopbm
convert X10 or X11 bitmap to portable bitmap
ybmtopbm
convert Bennet Yee "face" file into portable bitmap
pbmto10x
convert portable bitmap to Gemini 10x printer graphics
pbmtoascii
convert portable bitmap to ASCII graphic form
pbmtoatk
convert portable bitmap to Andrew Toolkit raster object
pbmtobbnbg
convert portable bitmap to BBN BitGraph graphics
pbmtocmuwm
convert portable bitmap to CMU window manager format
pbmtoepson
convert portable bitmap to Epson printer graphics
pbmtog3
convert portable bitmap to Group 3 FAX
pbmtogem
convert portable bitmap into GEM .img file
pbmtogo
convert portable bitmap to GraphOn graphics
pbmtoicon
convert portable bitmap to Sun icon
pbmtolj
convert portable bitmap to HP LaserJet graphics
pbmtomacp
convert portable bitmap to MacPaint
pbmtomgr
convert portable bitmap to MGR format
pbmtopi3
convert portable bitmap to Atari Degas .pi3
pbmtoplot
convert portable bitmap into Unix plot(5) file
pbmtoptx
convert portable bitmap to Printronix graphics
pbmtoxbm
convert portable bitmap to X11 bitmap
pbmtox10bm
convert portable bitmap to X10 bitmap
pbmtoybm
convert portable bitmap into Bennet Yee "face" file
pbmtozinc
convert portable bitmap to Zinc Interface Library icon
pbmlife
apply Conway's rules of Life to a portable bitmap
pbmmake
create a blank bitmap of a specified size
pbmmask
create a mask bitmap from a regular bitmap
pbmreduce
reduce a portable bitmap N times, using Floyd-Steinberg
pbmtext
render text into a bitmap
pbmupc
create a Universal Product Code bitmap
pbmmerge
merge wrapper routine
fitstopgm
convert FITS format to portable graymap
fstopgm
convert Usenix FaceSaver(tm) format to portable graymap
hipstopgm
convert HIPS format to portable graymap
lispmtopgm
convert a Lisp Machine bitmap file into pgm format
psidtopgm
convert PostScript "image" data to portable graymap
rawtopgm
convert raw grayscale bytes to portable graymap
pgmtofits
convert portable graymap to FITS format
pgmtofs
convert portable graymap to Usenix FaceSaver(tm) format
pgmtolispm
convert a portable graymap into Lisp Machine format
pgmtopbm
convert portable graymap to portable bitmap
pgmbentley
Bentleyize a portable graymap
pgmcrater
create cratered terrain by fractal forgery
pgmedge
edge-detect a portable graymap
pgmenhance
edge-enhance a portable graymap
pgmhist
print a histogram of the values in a portable graymap
pgmnorm
normalize contrast in a portable graymap
pgmoil
turn a portable graymap into an oil painting
pgmramp
generate a grayscale ramp
pgmtexture
calculate textural features on a portable graymap
pgmmerge
merge wrapper routine
giftoppm
convert GIF to portable pixmap
gouldtoppm
convert Gould scanner file to portable pixmap
ilbmtoppm
convert IFF ILBM to portable pixmap
imgtoppm
convert Img-whatnot to portable pixmap
mtvtoppm
convert MTV ray-tracer output to portable pixmap
pcxtoppm
convert PC Paintbrush format to portable pixmap
pgmtoppm
colorize a portable graymap into a portable pixmap
pi1toppm
convert Atari Degas .pi1 to portable pixmap
picttoppm
convert Macintosh PICT to portable pixmap
pjtoppm
convert HP PaintJet file to portable pixmap
qrttoppm
convert QRT ray-tracer output to portable pixmap
rawtoppm
convert raw RGB bytes to portable pixmap
rgb3toppm
combine three portable graymaps into one portable pixmap
sldtoppm
convert an AutoCAD slide file into a portable pixmap
spctoppm
convert Atari compressed Spectrum to portable pixmap
sputoppm
convert Atari uncompressed Spectrum to portable pixmap
tgatoppm
convert TrueVision Targa file to portable pixmap
ximtoppm
convert Xim to portable pixmap
xpmtoppm
convert XPM format to portable pixmap
yuvtoppm
convert Abekas YUV format to portable pixmap
ppmtoacad
convert portable pixmap to AutoCAD database or slide
ppmtogif
convert portable pixmap to GIF
ppmtoicr
convert portable pixmap to NCSA ICR graphics
ppmtoilbm
convert portable pixmap to IFF ILBM
ppmtopcx
convert portable pixmap to PC Paintbrush format
ppmtopgm
convert portable pixmap to portable graymap
ppmtopi1
convert portable pixmap to Atari Degas .pi1
ppmtopict
convert portable pixmap to Macintosh PICT
ppmtopj
convert portable pixmap to HP PaintJet file
ppmtopuzz
convert portable pixmap to X11 "puzzle" file
ppmtorgb3
separate a portable pixmap into three portable graymaps
ppmtosixel
convert portable pixmap to DEC sixel format
ppmtotga
convert portable pixmap to TrueVision Targa file
ppmtouil
convert portable pixmap to Motif UIL icon file
ppmtoxpm
convert portable pixmap to XPM format
ppmtoyuv
convert portable pixmap to Abekas YUV format
ppmdither
ordered dither for color images
ppmforge
fractal forgeries of clouds, planets, and starry skies
ppmhist
print a histogram of a portable pixmap
ppmmake
create a pixmap of a specified size and color
ppmpat
create a pretty pixmap
ppmquant
quantize colors down to a specified number
ppmquantall
script to run ppmquant on a set of pixmaps
ppmrelief
run a Laplacian Relief filter on a portable pixmap
ppmmerge
merge wrapper routine
anytopnm
script to attempt to convert any format to P?M
rasttopnm
convert Sun raster file to portable anymap
tifftopnm
convert TIFF file to portable anymap
xwdtopnm
convert X10 or X11 window dump to portable anymap
pnmtops
convert portable anymap to PostScript
pnmtorast
convert portable anymap to Sun raster file
pnmtotiff
convert portable anymap to TIFF file
pnmtoxwd
convert portable anymap to X11 window dump
pnmarith
perform arithmetic on two portable anymaps
pnmcat
concatenate portable anymaps
pnmconvol
general MxN convolution on a portable anymap
pnmcrop
crop all like-colored borders off a portable anymap
pnmcut
select a rectangular region from a portable anymap
pnmdepth
change the maxval in a portable anymap
pnmenlarge
enlarge a portable anymap N times
pnmfile
describe a portable anymap
pnmflip
perform one or more flip operations on a portable anymap
pnmgamma
perform gamma correction on a portable anymap
pnmindex
script to build a visual index of a bunch of anymaps
pnminvert
invert a portable anymap
pnmmargin
script to add a margin to a portable anymap
pnmnoraw
force a portable anymap into ASCII format
pnmpaste
paste a rectangle into a portable anymap
pnmrotate
rotate a portable anymap
pnmscale
scale a portable anymap
pnmshear
shear a portable anymap
pnmsmooth
script that uses pnmconvol to smooth a anymap
pnmtile
replicate a portable anymap into a specified size
pnmmerge
merge wrapper routine
pbmto4425
Display on an AT&T 4425 Ascii terminal.
pbmtoascii
A new improved version.
pbmtoln03
Convert to DEC LN03+.
pbmtolps
Fast PostScript creator.
pbmtopk
Conversion from a packed (PK) format font.
pktopbm
Conversion to a packed (PK) format font.
pbmclean
Flip isolated pixels.
pbmpscale
Enlarge pbm image with edge smoothing.
asciitopgm
Convert an ascii image into pgm.
pbmtopgm
Convert pbm to pgm by averaging areas.
rawtopgm
Handles input files without specification of the file size, assuming the input image is quadratic. It also supports a -tb (top bottom flip) option.
bioradtopgm
Conversion utility for files created by Biorad confocal microscopes.
spottopgm
Convert SPOT satellite images to pgm.
pgmkernel
Generate a convolution kernel.
pgmnoise
Create a pgm file with random pixels.
bmptoppm
Conversion from windows bitmap format.
ppmtobmp
Conversion to windows bitmap format.
ppmtomap
Extract all colours from a ppm file.
ppmtomitsu
Convert to Mitsubishi S340-10 printer format.
xvminitoppm
Convert an XV thumbnail picture to ppm.
ppmtoyuvsplit
Conversion from YUV triplets. (MPEG / JPEG).
yuvsplittoppm
Conversion to YUV triplets. (MPEG / JPEG).
ppm3d
Create a red/blue stereo image.
ppmbrighten
Change image saturation and value on an HSV map.
ppmchange
Change all pixels of one colour to another in a portable pixmap
ppmdim
Dim a ppm file down to total blackness.
ppmdist
Simplistic grayscale assignment for machine generated colour images.
ppmflash
Brighten a picture up to complete white-out
ppmmix
Blend together two portable pixmaps.
ppmnorm
Normalize the contrast in a portable pixmap.
ppmntsc
Make a portable pixmap look like taken from an American TV.
ppmqvga
Eight plane quantization.
ppmshift
Shift lines of a portable pixmap left or right by a random amount.
ppmspread
Displace a portable pixmap's pixels by a random amount.
ppmtopjxl
Convert a ppm file into an HP PaintJet XL PCL file.
pnmtops
New option (-nocenter) added.
pnmtofits
Replacement for pgmtofits
fitstopnm
Replacement for fitstopgm
pnmtosgi
Conversion to sgi image format.
sgitopnm
Conversion from sgi image format.
pnmtosir
Conversion to Solitaire image recorder format.
sirtopnm
Conversion from Solitaire image recorder format.
giftopnm
Replaces giftoppm. Examines the input image and produces a pbm, pgm, or ppm output.
pstopnm
Convert PostScript to pnm. Requires Ghostscript.
zeisstopnm
Conversion utility for files created by Zeiss confocal microscopes (the old standard).
pnmalias
Anti aliasing filter.
pnmcomp
Composite two portable anymaps together.
pnmcrop
New options added.
pnmpad
Add borders to anymap.

Other related software

For manipulation of PostScript images or for checking the PostScript, knowledge of and access to GhostScript (and even GhostView) are useful.

Since an increasing number of images are stored using JPEG, the JPEG package is almost a necessity. It includes djpeg and cjpeg.

To view the results, I strongly suggest xv.

The FrameMaker filter package comes with a converter called picttomif which can be used with ppmtopict to allow importing into FrameMaker.

The pixel editing package, xpaint allows editing of PPM, PGM, or PBM, as well as GIF files.

The Utah Raster Toolkit provides yet another set of tools with a slightly more professional use in mind.

I modified the pnmindex program so that it would handle a variety of input formats. I call my version anyindex.


Paul Chamberlain