PGM vs PPM
PPM stores three RGB samples per pixel without compression or alpha. It is easy to inspect in processing pipelines, but sacrifices compactness and rich metadata; select it when direct sample interchange is the priority.
Image format
Portable Graymap: simple uncompressed raster samples for image-processing pipelines.
Explore the format
Choose a target format for your PGM images.
Marked paths may need steps such as flattening, rasterization, tone mapping or animation loss.
Choose a source format to convert to PGM.
Marked paths may need steps such as flattening, rasterization, tone mapping or animation loss.
Portable Graymap
PGM is Netpbm’s simple grayscale raster format. It stores one intensity sample per pixel instead of RGB components. A header declares width, height and maximum sample value. This makes grayscale images easy to exchange between small programs without needing a palette or a general-purpose colour container.
P2 represents samples as text; P5 uses binary samples, one or two bytes according to maxval, up to 65535. Data is uncompressed and there is no separate alpha channel. The manual also describes an opacity-mask variant; a grayscale image and a mask can use the same storage but have different meanings.
Use PGM for grayscale processing and explicit single-channel masks. Document whether samples represent intensity, opacity or application data. Colour conversion to PGM removes chromatic information and requires a chosen grayscale mapping; increasing the sample precision later cannot recover removed colours or tonal values.
Netpbm stores these samples without compression. Reducing colour, thresholding or changing maxval can still lose information before storage; text and binary representations change the layout, not its image meaning.
This format belongs to the documented Pbmplus/Netpbm evolution. The history distinguishes the original bitmap idea, later channel models and library development.
Different formats, different trade-offs. Choose for the image and the workflow.
PPM stores three RGB samples per pixel without compression or alpha. It is easy to inspect in processing pipelines, but sacrifices compactness and rich metadata; select it when direct sample interchange is the priority.
PBM stores only black and white, one bit per pixel in its binary form. It fits bitonal masks and line art; tonal images need thresholding or dithering, so gradients cannot remain as continuous gray levels.
PAM extends Netpbm with explicit tuple types and depths, including RGB_ALPHA and GRAYSCALE_ALPHA. It suits channel-aware processing, but receiving tools must agree on the tuple meaning and it remains uncompressed.
PNG preserves decoded pixels losslessly and can carry alpha. It is useful for transparent graphics and screenshots; it does not preserve editable document layers or camera sensor data, and photographic files can be large.
PGM is Netpbm’s simple grayscale raster format. It stores one intensity sample per pixel instead of RGB components. A header declares width, height and maximum sample value. This makes grayscale images easy to exchange between small programs without needing a palette or a general-purpose colour container.
Netpbm stores these samples without compression. Reducing colour, thresholding or changing maxval can still lose information before storage; text and binary representations change the layout, not its image meaning.
It can be interpreted as an opacity mask by agreement, but the file contains only one channel. It does not combine grayscale image pixels with a separate alpha channel as PAM GRAYSCALE_ALPHA can.
Check the magic number, sample precision and tuple or channel meaning. Many simple readers accept only one binary image and 8-bit samples even though the specifications permit more.
Preserve maxval and colour interpretation when creating the rendered output. Grayscale and bitonal targets remove information deliberately; alpha requires an alpha-bearing tuple or a separate mask. Optional comments may not transfer.
Use PGM for grayscale processing and explicit single-channel masks. Document whether samples represent intensity, opacity or application data. Colour conversion to PGM removes chromatic information and requires a chosen grayscale mapping; increasing the sample precision later cannot recover removed colours or tonal values.