UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 43.24 Other PostScript Utilities Chapter 43
Printing
Next: VIII. Shell Programming
 

43.25 The Portable Bitmap Package

There are dozens of formats used for graphics files across the computer industry. There are tiff files, PICT files, and gif files. There are different formats for displaying on different hardware, different formats for printing on different printers, and then there are the internal formats used by graphics programs. This means that importing a graphics file from one platform to another (or from one program to another) can be a large undertaking, requiring a filter written specially to convert from one format to the next.

netpbm
The netpbm package can be used to convert between a wide variety of graphics formats. netpbm evolved from the original Portable Bitmap Package, pbmplus, which was written by Jef Poskanzer. A group of pbmplus users on the Internet cooperated to upgrade pbmplus; the result was netpbm.

The idea behind pbm is to use a set of very basic graphics formats that (almost) all formats can be converted into and then converted back from. This is much simpler than having converters to and from each individual format. These formats are known as pbm, pgm, and ppm: the portable bitmap, graymap, and pixmap formats. (A bitmap is a two-dimensional representation of an image; a graymap has additional information encoded that gives grayscale information for each bit; a pixmap encodes color information for each bit.) The name "pnm" is a generic name for all three portable interchange formats (with the n standing for "any"), and programs that work with all three are said to be "anymap" programs.

The netpbm package contains well over a hundred conversion programs. There are three basic kind of programs:

I frequently like to create X11 (1.31) bitmaps out of pictures in newspapers or magazines. The way I do this is to first scan the picture in on a Macintosh and save it as tiff or PICT format. Then I ftp (1.33) the file to our UNIX system and convert it to pnm format, and then use pbmtoxbm to convert it to X bitmap format. If the picture is too big, I use pnmscale on the intermediary pnm file. If the picture isn't right-side-up, I can use pnmrotate and sometimes pnmflip before converting the pnm file to X11 bitmap format.

The programs provided with the netpbm package are far too many to discuss in detail, and some of these formats are ones that you've probably never even heard of. But here's a summary of them. Table 43.2 lists the conversion programs. Table 43.3 lists the programs that perform various kinds of editing, enhancement, or transformations on image files.

Table 43.2: Image Format Conversion Programs
FormatTo pnmFrom pnm
ASCII graphicsasciitopgmpbmtoascii
AT&T 4425 terminal (132 col mode)pbmto4425
Abekas YUV bytesyuvtoppmppmtoyuv
Abekas YUV triplets (MPEG/JPEG)yuvsplittoppmppmtoyuvsplit
Andrew Toolkit raster objectatktopbmpbmtoatk
Atari Degas .pi1pi1toppmppmtopi1
Atari Degas .pi3pi3topbmpbmtopi3
Atari compressed Spectrum filespctoppm
Atari uncompressed Spectrum filesputoppm
AutoCAD database or slidesldtoppmppmtoacad
BBN BitGraph graphicspbmtobbnbg
Bennet Yee "face" fileybmtopbmpbmtoybm
Biorad confocal microscope filesbioradtopgm
CMU window manager bitmapcmuwmtopbmpbmtocmuwm
DEC LN03+pbmtoln03
DEC sixel formatppmtosixel
DDIF formatpnmtoddif
Encapsulated PostScript preview bitmappbmtoepsi
Epson printer graphicspbmtoepson
FITSfitstopnmpnmtofits
GEM .img filegemtopbmpbmtogem
GIFgiftopnmppmtogif
Gemini 10X printer graphicspbmto10x
Gould scanner filegouldtoppm
GraphOn graphics (compressed)pbmtogo
Group 3 fax fileg3topbmpbmtog3
HIPShipstopgm
HP LaserJet formatpbmtolj
HP PaintJetpjtoppmppmtopj
HP PaintJet XL PCL fileppmtopjxl
IFF ILBMilbmtoppmppmtoilbm
Img-whatnotimgtoppm
Lisp Machine bitmaplispmtopgmpgmtolispm
MGR bitmapmgrtopbmpbmtomgr
MacPaintmacptopbmpbmtomacp
Macintosh PICTpicttoppmppmtopict
Mitsubishi S340-10 printer formatppmtomitsu
Motif UIL icon fileppmtouil
NCSA ICR format ppmtoicr
PCXpcxtoppmppmtopcx
packed (PK) format fontpktopbmpbmtopk
Photo-CD filehpcdtoppm
PostScript "image" datapsidtopgm
PostScript (pstopnm uses ghostscript)pstopnmpnmtops
Fast PostScript creatorpbmtolps
Printronix printer graphicspbmtoptx
SGI image filesgitopnmpnmtosgi
Solitaire image recorder formatsirtopnmpnmtosir
SPOT satellite imagesspottopgm
Sun iconicontopbmpbmtoicon
Sun rasterfilerasttopnmpnmtorast
TIFF filetifftopnmpnmtotiff
TrueVision Targa filetgatoppmppmtotga
Unix plot(5) filepbmtoplot
Usenix FaceSaver(tm)fstopgmpgmtofs
Windows (PC) bitmapbmptoppmppmtobmp
X10 bitmapxbmtopbmpbmtox10bm
X10 window dumpxwdtopnm
X11 "puzzle" fileppmtopuzz
X11 bitmapxbmtopbmpbmtoxbm
X11 pixmapxpmtoppmppmtoxpm
X11 window dumpxwdtopnmpnmtoxwd
Xim fileximtoppm
XV "thumbnail" picturexvminitoppm
Zeiss confocal microscopeszeisstopnm
Zinc bitmappbmtozinc
doodle brushbrushtopbm
output from the MTV or PRT ray tracersmtvtoppm
output from the QRT ray tracerqrttoppm
portable bitmappgmtopbm
portable graymappbmtopgm
ppmtopgm
portable pixmappgmtoppm
raw RGB bytesrawtoppm
raw grayscale bytesrawtopgm
textpbmtext
three portable graymapsrgb3toppmppmtorgb3
unknownanytopnm

Table 43.3: Manipulating pnm Files
ProgramPurpose
pbmlifeApply Conway's rules of Life to a portable bitmap.
pbmmakeCreate a blank bitmap of a specified size.
pbmmaskCreate a mask bitmap from a regular bitmap.
pbmpscaleEnlarge pbm image with edge smoothing.
pbmreduceRead a portable bitmap and reduce it N times.
pbmupcCreate a Universal Product Code bitmap.
pgmbentleyBentleyize a portable graymap.
pgmcraterCreate cratered terrain by fractal forgery.
pgmedgeEdge-detect a portable graymap.
pgmenhanceEdge-enhance a portable graymap.
pgmhistPrint a histogram of the values in a portable graymap.
pgmkernelGenerate a convolution kernel (for pnmconvol use).
pgmnoiseCreate a PGM made up of white noise.
pgmnormNormalize the contrast in a portable graymap.
pgmoilTurn a portable graymap into an oil painting.
pgmrampGenerate a grayscale ramp.
pgmtextureCalculate textural features on a portable graymap.
pnmaliasAntialias a PNM (remove jaggies).
pnmarithPerform arithmetic on two portable anymaps.
pnmcatConcatenate portable anymaps.
pnmcompCreate composite image from two PNMs.
pnmconvolGeneral MxN convolution on a portable anymap.
pnmcropCrop a portable anymap.
pnmcutCut a rectangle out of a portable anymap.
pnmdepthChange the maxval in a portable anymap.
pnmenlargeRead a portable anymap and enlarge it N times.
pnmfileDescribe a portable anymap.
pnmflipPerform one or more flip operations on a portable anymap.
pnmgammaPerform gamma correction on a portable anymap.
pnmhisteqHistogram equalize a PNM.
pnmhistmapDraw a histogram for a PGM or PPM file.
pnmindexBuild a visual index of a bunch of anymaps.
pnminvertInvert a portable anymap.
pnmmarginAdd a border to a portable anymap.
pnmnlfiltMiscellaneous non-linear filters.
pnmnorawForce a portable anymap into plain format.
pnmpadAdd borders to a PNM.
pnmpastePaste a rectangle into a portable anymap.
pnmrotateRotate a portable anymap by some angle.
pnmscaleScale a portable anymap.
pnmshearShear a portable anymap by some angle.
pnmsmoothSmooth out an image.
pnmtileReplicate a portable anymap into a specified size.
ppm3dMerge two PPM files into a red/blue (3-D glasses) PPM.
ppmbrightenChange image saturation and value on an HSV map.
ppmchangeChange one color into another color.
ppmdimDim a portable pixmap (similar to ppmbrighten).
ppmdistSimplistic grayscale convert for color images.
ppmditherOrdered dither for color images.
ppmflashBrighten a picture (similar to ppmbrighten).
ppmforgeFractal forgeries of clouds, planets, and starry skies.
ppmhistPrint a histogram of a portable pixmap.
ppmmakeCreate a pixmap of a specified size and color.
ppmtomapExtract all colors from a PPM file.
ppmmixBlend together two portable pixmaps (fade between).
ppmnormNormalize the contrast in a portable pixmap.
ppmntscMake PPM look like a television image (dim every other row).
ppmpatMake a pretty pixmap.
ppmquantQuantize the colors in a portable pixmap down to a specified number.
ppmquantallRun ppmquant on a bunch of files all at once, so they share a common colormap.
ppmqvgaEight plane quantization.
ppmreliefRun a Laplacian relief filter on a portable pixmap.
ppmshiftShift rows randomly left and right (water reflection).
ppmspreadDisplace pixels by random amounts (unfocus image).
bitmaps
The netpbm package is also distributed with a set of public domain bitmaps. We've put these bitmaps on the CD-ROM as well.

- LM, JP


Previous: 43.24 Other PostScript Utilities UNIX Power ToolsNext: VIII. Shell Programming
43.24 Other PostScript Utilities Book IndexVIII. Shell Programming

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System