Netpbm Format - File Format Description

File Format Description

Each format differs in what colors it is designed to represent:

  • PBM is for bitmaps (black and white, no grays)
  • PGM is for grayscale
  • PPM is for "pixmaps" which represent full RGB color.

Each file starts with a two-byte magic number (in ASCII) that explains the type of file it is (PBM, PGM, and PPM) and its encoding (ASCII or binary). The magic number is a capital P followed by a single digit number.

Magic Number Type Encoding
P1 Portable bitmap ASCII
P2 Portable graymap ASCII
P3 Portable pixmap ASCII
P4 Portable bitmap Binary
P5 Portable graymap Binary
P6 Portable pixmap Binary

The ASCII based formats allow for human-readability and easy transport to other platforms (so long as those platforms understand ASCII), while the binary formats are more efficient both at saving space in the file, as well as being easier to parse due to the absence of whitespace.

When using the binary formats, PBM uses 1 bit per pixel, PGM uses 8 bits per pixel, and PPM uses 24 bits per pixel: 8 for red, 8 for green, 8 for blue.

Read more about this topic:  Netpbm Format

Famous quotes containing the words file and/or description:

    A common and natural result of an undue respect for law is, that you may see a file of soldiers, colonel, captain, corporal, privates, powder-monkeys, and all, marching in admirable order over hill and dale to the wars, against their wills, ay, against their common sense and consciences, which makes it very steep marching indeed, and produces a palpitation of the heart.
    Henry David Thoreau (1817–1862)

    Whose are the truly labored sentences? From the weak and flimsy periods of the politician and literary man, we are glad to turn even to the description of work, the simple record of the month’s labor in the farmer’s almanac, to restore our tone and spirits.
    Henry David Thoreau (1817–1862)