What is PBM? Portable Bitmap Format Explained
The simplest Netpbm format, storing one-bit black-and-white images in a plain or binary layout.
Last updated:
What is PBM?
PBM, the Portable Bitmap format, is the simplest member of the Netpbm family of image formats. It was invented by Jef Poskanzer in the mid-1980s to allow images to be sent reliably through email and exchanged easily between different systems.
A PBM file stores a bi-level (black-and-white) image where each pixel is a single bit. Files start with a two-byte magic number, P1 for the plain ASCII variant and P4 for the binary (raw) variant, followed by the image width and height and then the pixel data. The deliberately minimal structure makes the format trivial to read and write.
How PBM Works
A PBM file consists of a tiny ASCII header followed by pixel data. The header is a two-byte magic number, then the width and height as ASCII decimal numbers separated by whitespace.[1] In the plain P1 variant each pixel is the ASCII character 0 or 1; in the raw P4 variant pixels are packed eight to a byte. By convention a 1 bit denotes black and 0 denotes white, the reverse of most conventions.[1]
History and the Netpbm Family
Jef Poskanzer created the format in the mid-1980s so images could survive transmission through 7-bit email gateways, which is why the plain variant uses only printable ASCII.[2] PBM is the bi-level base of the Netpbm family, which extends upward to grayscale (PGM) and full color (PPM); the three are collectively addressed by the PNM specification.[3]
PBM vs Other Formats
Unlike compressed formats such as PNG or GIF, PBM applies no compression in its plain form and only minimal bit packing in its raw form, so files are larger but trivially simple to parse.[2] This simplicity makes it a popular intermediate format in image-processing pipelines and the Netpbm toolkit, where conversions chain together easily.[3]
MKV Technical Specifications
PBM vs Other Image Formats
| Feature | PBM | PNG | BMP |
|---|---|---|---|
| Type | Raster | Raster | Raster |
| Color depth | 1-bit (bilevel)[1] | Up to 16-bit | Up to 32-bit |
| Compression | None[1] | Lossless | None or RLE |
| Transparency | No | Yes | Limited |
| Encoding | ASCII or binary[1] | Binary | Binary |
| Best for | Simple bitmaps[2] | Web graphics | Windows images |
PBM stores only black-and-white pixels in a deliberately simple format, trading efficiency and features for ease of generation and parsing.
Advantages & Disadvantages
Advantages
The minimal header and 1-bit pixels make PBM one of the easiest image formats to read and write programmatically.
The P1 ASCII variant stores pixels as human-readable 0s and 1s, useful for debugging and quick generation.
Designed for cross-platform exchange, it works consistently across systems and many image tools.
For purely black-and-white images, 1-bit pixels keep the binary variant compact.
Disadvantages
PBM cannot represent grayscale or color; those require the related PGM and PPM formats.
Pixel data is stored uncompressed, so it is inefficient for large images compared with PNG.
The plain P1 form is space-inefficient because each pixel is written as text.
Common Use Cases
PBM is used where a dead-simple, portable bi-level image is all that is needed.
Programmatic image generation | FileFormer
Scripts and programs emit PBM because the format is trivial to write by hand or in code.
Image-processing pipelines | FileFormer
Netpbm tools use PBM as an intermediate format when converting or manipulating bitmaps.
Fax and line-art data | FileFormer
Bi-level content such as scanned text or fax-style images maps naturally onto PBM.
Convert PBM Files Free
Use our free online image converter to convert PBM and other formats - no signup, no watermarks.
Try Image Converter FreeFrequently Asked Questions
What is the difference between PBM, PGM, and PPM?
PBM stores 1-bit black-and-white images, PGM stores grayscale images, and PPM stores full-color images. Together they form the Netpbm (PNM) family.
What do the magic numbers P1 and P4 mean?
P1 marks a plain ASCII PBM file, while P4 marks the binary (raw) PBM variant. Both store the same kind of 1-bit image.
Who invented the PBM format?
Jef Poskanzer created PBM in the mid-1980s; it became the basis of the Pbmplus and later Netpbm toolkits.
Is PBM compressed?
No. PBM stores pixel data uncompressed, which keeps the format simple but inefficient for large images.
Why would anyone still use PBM?
Its simplicity makes it ideal as an intermediate format in image-processing pipelines and for quick programmatic generation of bitmaps.