Portable Bitmap .PBM, .PGM, .PPM, .PNM Files

 

The PNM filter imports and exports bitmap images from portable bitmap files.

 

File Description

The portable pixmap format .PPM, the portable graymap format .PGM, and the portable bitmap format .PBM are image file formats originally designed to be easily exchanged between platforms. They are also sometimes referred to collectively as the portable anymap format .PNM.

 

File Name Extensions

·      Portable Bitmap, 1 bit per pixel monochrome images that typically use the file name extension .PBM but can also use .PNM

·      Portable Gray Map, single-channel grayscale images that typically use the file name extension .PGM but can also use .PNM

·      Portable Pixel Map, three-channeled or paletted images that typically use the file name extension .PPM but can also use .PNM

 

Each of these three variants has both an ASCII encoding and a binary encoding, both of which can be imported.

 

File Format

The PBM, PGM, and PPM formats are each designed to be as simple as possible. Each starts out with a header, and the bitmap data follows immediately after. The header is always written in ASCII, and data items are separated by white space (blanks, tabs, carriage returns, or linefeeds). The data portion of each file type can be written in either ASCII or binary form.

 

These file formats originated on UNIX workstations, and are commonly used on UNIX, Linux, and Solaris workstations. Support for these file formats has also become more widespread in Windows-based imaging applications.

 

PBM Header

A PBM header consists of the following entries, each separated by white space:

 

MagicValue Literally P1 for ASCII version, P4 for binary

ImageWidth Width of image in pixels (ASCII decimal value)

ImageHeight Height of image in pixels (ASCII decimal value)

 

PGM Header

A PGM header consists of the following entries, each separated by white space:

 

MagicValue Literally P2 for ASCII version, P5 for binary

ImageWidth Width of image in pixels (ASCII decimal value)

ImageHeight Height of image in pixels (ASCII decimal value)

MaxGrey Maximum gray value (ASCII decimal value)

 

PPM Header

A PPM header consists of the following entries, each separated by white space:

 

MagicValue Literally P3 for ASCII version, P6 for binary

ImageWidth Width of image in pixels (ASCII decimal value)

ImageHeight Height of image in pixels (ASCII decimal value)

MaxGrey Maximum color value (ASCII decimal value)

 

Image Data

After the header is a series of lines describing widthxheight pixels. For PPM, each pixel contains three ASCII decimal values between 0 and the specified maximum value, starting at the top-left corner of the pixmap, proceeding in normal English reading order. The three values for each pixel represent red, green, and blue, respectively; a value of 0 means that color is turned off, and the maximum value means that color is "maxxed out." For PBM and PGM, there is only one ASCII decimal value per pixel. For PBM, the maximum value is implicitly 1. You can include comments in the PBM file. Characters from a # character to the next end-of-line are ignored. There is a suggested maximum of 70 characters per line, but this is not an actual restriction.

 

Example

Below is an example of a small pixmap in this format:

P3

# feep.ppm

4 4

15

 0  0  0    0  0  0    0  0  0   15  0 15

 0  0  0    0 15  7    0  0  0    0  0  0

 0  0  0    0  0  0    0 15  7    0  0  0

15  0 15    0  0  0    0  0  0    0  0  0

 

Format(s) Supported for Import

device-independent bitmap; 1, 8, 24 bit per pixel

 

Format(s) Supported for Export

device-independent bitmap; 24 bit per pixel

 

Import Method

Choose the File | Import command.

 

Export Method

Choose the File | Export command or select an image module and choose the File | Save Data command.

 

Export Options

Specify the export options in the Export Options dialog.

 

Export Restrictions/Limitations

Exported images are always written in 24-bit per pixel format. If the export data has fewer bits per pixel, it is expanded to 24 bits during the export procedure. The current implementation always exports in binary rather than ASCII format.

 

Reference

 

 

See Also

File Format Chart

File | Import

File | Export

File | Save Data

Export Options