Netpbm is a package of graphics programs and programming libraries.
There are over 220 separate programs in the package, most of which have pnmscale and giftopnm__.
All of the programs work with a set of graphics formats called the pbm__(5)?, pgm(5), ppm(5), and pam(5). The first three of these are sometimes known generically as pnm. Many of the Netpbm programs convert from a Netpbm format to another format or vice versa. This is so you can use the Netpbm programs to work on graphics of any format. It is also common to use a combination of Netpbm programs to convert from one non-Netpbm format to another non-Netpbm format. Netpbm has converters for over 80 graphics formats, and as a package Netpbm lets you do more graphics format conversions than any other computer graphics facility.
The Netpbm formats are all raster formats, i.e. they describe an image as a matrix of rows and columns of pixels. In the PBM format, the pixels are black and white. In the PGM format, pixels are shades of gray. In the PPM format, the pixels are in full color. The PAM format is more sophisticated. A replacement for all three of the other formats, it can represent matrices of general data including but not limited to black and white, grayscale, and color images.
Programs designed to work with PBM images have
All Netpbm programs designed to read PGM images see PBM images as if they were PGM too. All Netpbm programs designed to read PPM images see PGM and PBM images as if they were PPM. See the section
Programs that have pnmtogif creates a black and white GIF output image if its input is PBM or PGM, but a color GIF output image if its input is PPM. And pnmscale produces an output image of the same format as the input. A ppmscale__ program would read all three PNM input formats, but would see them all as PPM and would always generate PPM output.
If it seems wasteful to you to have three separate PNM formats, be aware that there is a historical reason for it. In the beginning, there were only PBMs. PGMs came later, and then PPMs. Much later came PAM, which realizes the possibility of having just one aggregate format.
A program that uses the PGM library to read an image can read a PBM image as well as a PGM image. The program sees the PBM image as if it were the equivalent PGM image, with a maxval of 255.
The Netpbm programs are generally useful run by a person from a command shell, but are also designed to be used by programs. A common characteristic of Netpbm programs is that they are simple, fundamental building blocks. They are most powerful when stacked in pipelines. Netpbm programs do not use graphical user interfaces (in fact, none of them display graphics at all) and do not seek input from a user.
There are a few options that are present on all programs that are based on the Netpbm libraries, including virtually all Netpbm programs. These are not mentioned in the individual man pages for the programs.
Suppress all informational messages that would otherwise be issued to Standard Error. (To be precise, this only works to the extent that the program in question implements the Netpbm convention of issuing all informational messages via the pm_message() service of the Netpbm libraries).
Instead of doing anything else, report the version of the libpbm library linked with the program (it may have been linked statically into the program, or dynamically linked at run time). Normally, the Netpbm programs and the libraries are installed at the same time, so this tells you the version of the program and all the other Netpbm libraries and files it uses as well.
Here is a directory of the Netpbm programs. You can also use man -k to search for a program that does what you want.
convert series of PPM frames to an MPEG movie
convert JFIF/JPEG/EXIF file to Netpbm format
convert PPM to JPEG/JFIF/EXIF format
convert any graphics format to Netpbm format
convert Windows or OS/2 Bitmap file to PPM
convert PPM to Windows or OS/2 Bitmap file
convert Windows icon file to PPM
convert PPM to Windows icon file
convert GIF to portable anymap
convert PPM to GIF
convert Netpbm format to Portable Network Graphics
convert PNG (Portable Network Graphics) to Netpbm formats
convert Palm pixmap to Netpbm formats
convert Netpbm formats to Palm pixmap
convert JBIG BIE (compressed bitmap) to PBM
convert PBM to JBIG BIE (compressed bitmap)
convert Netpbm image to Fiasco (wfa) highly compressed format
convert Fiasco (wfa) highly compressed format to Netpbm image
convert photo CD to PPM
convert PBM to Nokia Smart Messaging Format (SMF)
convert PBM to WAP (Wireless App Protocol) Wireless Bitmap
convert WAP (Wireless App Protocol) Wireless Bitmap to PBM
convert Atari Neochrome (.neo) image to PPM
convert PPM image to Atari Neochrome (.neo)
convert from PBM to Microdesign (for Amstrad PCWs)
convert from Microdesign (for Amstrad PCWs) to PBM
convert Andrew Toolkit raster object to PBM
convert PBM to Andrew Toolkit raster object
convert Xerox doodle brushes to PBM
convert CMU window manager format to PBM
convert Group 3 FAX to PBM
convert PBM to Group 3 FAX
convert Sun icon to PBM
convert PBM to Sun icon
convert GEM .img format to PBM or pixmap
convert !MacPaint? to PBM
convert PBM to !MacPaint?
convert MGR format to PBM
convert PBM to MGR format
convert Atari Degas .pi3 to PBM
convert PBM to Atari Degas .pi3
convert X10 or X11 bitmap to PBM
convert PBM to X11 bitmap
convert PBM to X10 bitmap
convert Bennet Yee
convert PBM into Bennet Yee
convert PBM to Gemini 10x printer graphics
convert PBM to ASCII graphic form
convert ASCII character graphics to PGM
convert PBM to BBN !BitGraph? graphics
convert PBM to CMU window manager format
convert PBM to Epson printer graphics
convert PBM into GEM .img file
convert PBM to !GraphOn? graphics
convert PBM to HP !LaserJet? black and white graphics
convert PPM to HP !LaserJet? color graphics (PCL)
convert HP !PaintJet? file to PPM
convert PPM to HP !PaintJet? file
convert HP Thinkjet printer stream to PBM
convert PBM into Unix plot(5)? file
convert PBM to Printronix graphics
convert PBM to Zinc Interface Library icon
convert FITS format to portable anymap
convert Netpbm formats to FITS format
convert Usenix !FaceSaver?(tm) format to PGM
convert PGM to Usenix !FaceSaver?(tm) format
convert HIPS format to PGM
convert a Lisp Machine bitmap file into PGM format
convert PGM into Lisp Machine format
convert Netpbm formats to Postscript
convert Postscript to Netpbm formats
convert PBM image to Postscript using lines
convert a PBM image to encapsulated Postscript preview bitmap
convert PBM images to Postscript using G3 fax compression.
convert raw grayscale bytes to PGM
convert PGM to PBM
convert Gould scanner file to PPM
convert IFF ILBM to PPM
convert PPM to IFF ILBM
convert Img-whatnot to PPM
convert MTV ray-tracer output to PPM
convert PC Paintbrush format to PPM
colorize a portable graymap into a PPM
convert Atari Degas .pi1 to PPM
convert PPM to Atari Degas .pi1
convert Macintosh PICT to PPM
convert PPM to Macintosh PICT
convert QRT ray-tracer output to PPM
convert raw RGB bytes to PPM
convert an AutoCAD slide file into a PPM
convert Atari compressed Spectrum to PPM
convert Atari uncompressed Spectrum to PPM
convert !TrueVision? Targa file to PPM
convert PPM to !TrueVision? Targa file
convert Xim to PPM
convert XPM format to PPM
convert PPM to XPM format
convert Abekas YUV format to PPM
convert Encoder/Berkeley YUV format to PPM
convert PPM to Encoder/Berkeley YUV format
convert PPM to Abekas YUV format
convert PPM to 3 subsampled raw YUV files
merge 3 subsampled raw YUV files to one PPM
convert PPM to AutoCAD database or slide
convert PPM to NCSA ICR graphics
convert PPM to PC Paintbrush format
convert PPM to portable graymap
convert PPM to X11
convert Sun raster file to Netpbm formats
convert Netpbm formats to Sun raster file
convert TIFF file to portable anymap
convert Netpbm formats to TIFF RGB file
convert Netpbm formats to TIFF CMYK file
convert X10 or X11 window dump to Netpbm formats
convert Netpbm formats to X11 window dump
convert regular Netpbm format image into plain Netpbm format
convert PBM file to PGM by averaging areas
convert 411 (Sony Mavica) to PPM
convert PPM to DEC sixel format
convert PPM to Motif UIL icon file
convert Santa Barbara Instrument Group CCD file to PGM
convert Parallax XVideo JPEG to sequence of PPM files
convert PNM to Utah Raster Toolkit (urt/rle) file
convert Utah Raster Toolkit (urt/rle) file to PNM
convert PPM to Interleaf
convert Interleaf to PPM
convert Biorad confocal image to PGM
convert PGM image to Dec LN03+ Sixel image
convert PBM image to packed format (PK) font
convert packed format (PK) font to PBM image
All of these generate Netpbm format output.
create a blank PBM image of a specified size
create a PPM image of a specified size and color
generate a grayscale ramp
create a pretty PPM image
create a spectrum-like image with colors fading together.
create a PGM image of white noise
render text into a PBM image
create a Universal Product Code PBM image
generate a CIE color map PPM image
create a printer test pattern page in PBM format
All of these work on the Netpbm formats
Add text to an image
add a shadow to an image so it looks like it's floating
brighten or dim an image -- change saturation and value
dim an image - different way from ppmbrighten
reduce a PBM N times, using Floyd-Steinberg
normalize contrast in a PGM image
normalize contrast in a PPM image
enlarge a PBM image with edge smoothing
scale an image with high precision
scale an image quickly with low precision
ordered dither for color images
quantize colors in an image down to a specified number
quantize colors down to a specified number on many files
run a Laplacian Relief filter on a PPM
perform arithmetic on two images
add borders to an image
create composite (overlay) of images
mix (overlay) two images.
crop all like-colored borders off an image
select a rectangular region from an image
change the maxval in an image
enlarge an image N times
perform one or more flip operations on an image
scale up an image by interpolating between pixels
scale by non-integer values using pnminterp and pnmscale
invert an image
perform gamma correction on an image
add a margin to an image
paste a rectangle into an image
rotate an image
shear an image
smooth am image
replicate an image into a specified size
remove lone pixels (snow) from a PBM image
antialias an image
change all of one color to another in PPM image
shift lines of PPM image left or right a random amount
move pixels of PPM image a random amount
general MxN convolution on an image
combine three portable graymaps into one PPM
separate a PPM into three portable graymaps
apply Conway's rules of Life to a PBM image
map colors to high contrast grayscales arbitrarily
adjust colors so they are legal for NTSC or PAL television
These all work on the Netpbm formats as input.
describe an image's vital characteristics
measure difference between two images
edge-detect a PGM image
edge-enhance a PGM image
print grayscale values for a row or column of a PGM image
calculate textural features on a PGM image
print a histogram of the values in a PGM image
print a histogram of a PPM
generate a map of all colors in an image
create a mask bitmap from a regular bitmap
create mask of areas of a certain color in an image
split a multi-image Netpbm file into multiple 1-image files
build a visual index of a bunch of Netpbm images
build a visual index of a photo CD from PCD overview file
build multiple Netpbm images into a single montage image
Bentleyize a PGM image
create cratered terrain by fractal forgery
turn a PNM or PAM image into an oil painting
fractal forgeries of clouds, planets, and starry skies
generate a convolution kernel
Make an image lined so it looks like an old TV
Display PBM image on AT
Uncatalogued As Yet
The Netpbm programming libraries, libpbm(3)?, libpgm(3)?, libppm(3)?, and libpnm(3)?, make it easy to write programs that manipulate graphic images. Their main function is to read and write files in the Netpbm format, and because the Netpbm package contains converters for all the popular graphics formats, if your program reads and writes the Netpbm formats, you can use it with any formats.
But the libraries also contain some utility functions, such as character drawing and RGB/YCrCb conversion.
The libraries have the conventional C linkage. Virtually all programs in the Netpbm package are based on the Netpbm libraries.
As a collection of primitive tools, the power of Netpbm is multiplied by the power of all the other unix tools you can use with them. These notes remind you of some of the more useful ways to do this. Often, when people want to add high level functions to the Netpbm tools, they have overlooked some existing tool that, in combination with Netpbm, already does it.
Often, you need to apply some conversion or edit to a whole bunch of files.
As a rule, Netpbm programs take one input file and produce one output file, usually on Standard Output. This is for flexibility, since you so often have to pipeline many tools together.
for i in *.png; do pngtopnm $i | ppmtojpeg
Or you might just generate a stream of individual shell commands, one per file, with awk or perl. Here's how to brighten 30 YUV images that make up one second of a movie, keeping the images in the same files:
ls *.yuv .br | perl -ne 'chomp; print yuvtoppm $_ | ppmbrighten -v 100 | ppmtoyuv mv tmp$$.yuv $_0 ' .br | sh
The tools find (with the -exec option) and xargs are also useful for simple manipulation of groups of files.
Some shells' abc.png__. Try:
It works in the other direction too, if you have a program that makes you name its output file and you want the output to go through a Netpbm tool.
Other Graphics Software
Netpbm contains primitive building blocks. It certainly is not a complete graphics library.
The first thing you will need to make use of any of these tools is a viewer. zgv is a good viewer to use on a GNU/Linux system with the SVGALIB graphics display driver library. You can find zgv at ftp://ftp.ibiblio.org/pub/Linux/apps/graphics/viewers/svga .
zgv even has a feature in it wherein you can visually crop an image and write an output file of the cropped image using pnmcut. See the -s option to zgv.
For the X inclined, there is also xzgv. See __ftp://metalab.unc.edu/pub/Linux/apps/graphics/viewers/X__.
xloadimage and its extension xli are also common ways to display a graphic image in X.
!ImageMagick is like a visual version of Netpbm. Using the X/Window system on Unix, you can do basic editing of images and lots of format conversions. The package does include at least some non-visual tools. Convert, Mogrify, Montage, and Animate are popular programs from the !ImageMagick package. !ImageMagick runs on Unix, Windows, Windows NT, Macintosh, and VMS.
The Gimp is a visual image editor for Unix and X, in the same category as the more famous, less capable, and much more expensive Adobe Photoshop, etc. for Windows. See __http://www.gimp.org__.
The file program looks at a file and tells you what kind of file it is. It recognizes most of the graphics formats with which Netpbm deals, so it is pretty handy for graphics work. Netpbm's anytopnm program depends on file. See __ftp://ftp.astron.com/pub/file__.
The Utah Raster Toolkit serves a lot of the same purpose as Netpbm, but without the emphasis on format conversions. This package is based on the RLE format, which you can convert to and from the Netpbm formats. __http://www.cs.utah.edu/research/projects/alpha1/urt.html__ gives some information on the Utah Raster Toolkit, but does not tell where to get it.
There are some Netpbm-like graphics tools distributed by the Army High Performance Computing Research Center at __http://www.arc.umn.edu/gvl-software/media-tools.html__. These operate directly on non-Netpbm format images, so they aren't included in the Netpbm package. However, you can use them with any image format by using the Netpbm format converters.
Ivtools is a suite of free X Windows drawing editors for Postscript, Tex, and web graphics production, as well as an embeddable and extendable vector graphic shell. It uses the Netpbm facilities. See __http://www.ivtools.org__.
Ilib is a C subroutine library with functions for adding text to an image (as you might do at a higher level with pbmtext, pnmcomp, etc.). It works with Netpbm input and output. Find it at http://www.radix.net/cknudsen/Ilib__. Netpbm also includes character drawing functions in the libppm library, but they do not have as fancy font capabilities (see ppmlabel__ for an example of use of the Netpbm character drawing functions).
pnm2ppa converts to HP's pbmtoppa and handles, notably, color. However, it is more of a printer driver than a Netpbm-style primitive graphics building block. See __http://sourceforge.net/project/?group_id=1322__.
The program morph morphs one image into another. It uses Targa format images, but you can use tgatoppm and ppmtotga to deal with that format. You have to use the graphical (X/Tk) Xmorph to create the mesh files that you must feed to morph. morph is part of the Xmorph package. See __http://www.colorado-research.com/gourlay/software/Graphics/Xmorph__.
To create an animated GIF, or extract a frame from one, use gifsicle. gifsicle converts between animated GIF and still GIF, and you can use ppmtogif and giftopnm to connect up to all the Netpbm utilities. See __http://www.lcdf.org/gifsicle__.
To convert an image of text to text (optical character recongition - OCR), use gocr (think of it as an inverse of pbmtext). See __http://altmark.nat.uni-magdeburg.de/jschulen/ocr/__.
__http://schaik.com/pngsuite__ contains a PNG test suite -- a whole bunch of PNG images exploiting the various features of the PNG format.
Another version of pnmtopng/pngtopnm is at __http://www.schaik.com/png/pnmtopng.html__. The version in Netpbm was actually based on that package a long time ago, and you can expect to find better exploitation of the PNG format, especially recent enhancements, in that package. It may be a little less consistent with the Netpbm project and less exploitive of recent Netpbm format enhancements, though.
jpegtran Does some of the same transformations as Netpbm is famous for, but does them specifically on JPEG files and does them without loss of information. By contrast, if you were to use Netpbm, you would first decompress the JPEG image to Netpbm format, then transform the image, then compress it back to JPEG format. In that recompression, you lose a little image information because JPEG is a lossy compression. jpegtran comes with the Independent Jpeg Group's (http://www.ijg.org) JPEG library.
Some tools to deal with EXIF files (see also Netpbm's jpegtopnm and pnmtojpeg): To dump (interpret) an EXIF header: Exifdump ((http://topo.math.u-psud.fr/bousch/exifdump.py) or Jhead (http://www.sentex.net/mwandel/jhead).
A Python EXIF library and dumper: http://pyexif.sourceforge.net.
Other Graphics Formats
People never seem to tire of inventing new graphics formats, often completely redundant with pre-existing ones. Netpbm cannot keep up with them. Here is a list of a few that we know Netpbm does not handle (yet).
CAL (originated by US Department Of Defense, favored by architects). http://www.landfield.com/faqs/graphics/fileformats-faq/part3/section-24.html
array formats dx, general, netcdf, CDF, hdf, cm
Windows Meta File (.WMF). Libwmf converts from WMF to things like Latex, PDF, PNG. Some of these can be input to Netpbm.
Netpbm is based on the Pbmplus package by Jef Poskanzer, first distributed in 1988 and maintained by him until 1991. But the package contains work by countless other authors, added since Jef's original work. In fact, the name is derived from the fact that the work was contributed by people all over the world via the Internet, when such collaboration was still novel enough to merit naming the package after it.