LinuxCommandLibrary

bmptoppm

Convert BMP images to PPM format

TLDR

View documentation for the current command

$ tldr bmptopnm
copy

SYNOPSIS

bmptoppm [-windows|-os2] [-verbose] [bmpfile]

PARAMETERS

-windows
    Assume input is Windows BMP format (default)

-os2
    Assume input is OS/2 BMP format

-verbose
    Print details about the BMP (size, depth, colormap) to stderr

bmpfile
    Input BMP file; if omitted, read from stdin

DESCRIPTION

bmptoppm is a utility from the Netpbm suite that reads Microsoft Windows or OS/2 BMP files and converts them to Netpbm's portable formats: PBM for monochrome, PGM for grayscale, and PPM for color images.

It handles various BMP pixel depths: 1-bit (monochrome), 4-bit and 8-bit paletted, 15/16-bit (RGB 555/565), 24-bit RGB, and 32-bit RGBA. RLE compression is supported for 4-bit, 8-bit, and 24-bit images. Colormaps are mapped to RGB values, and dithering is applied where needed for reduced color depths.

Input is read from stdin or a named file; output always goes to stdout as raw Netpbm data. This makes it suitable for piping in image processing workflows. Verbose mode reports image dimensions, depth, and compression details.

Commonly used to import Windows BMPs into Unix/Linux environments for further manipulation with tools like pnmscale or ppmtogif. Limitations include no support for BMP v5 features like JPEG/PNG compression or alpha transparency preservation.

CAVEATS

Ignores alpha channels in 32-bit BMPs (outputs RGB PPM); limited RLE support; no handling of BMP v4/v5 extensions like embedded JPEG/PNG or gamma correction.

OUTPUT SELECTION

Auto-selects PBM (1-bit), PGM (grayscale), PPM (color) based on BMP depth.
Paletted images use dithering for RGB conversion.

EXAMPLE

bmptoppm -verbose image.bmp > image.ppm
Convert BMP to PPM with verbose info.

HISTORY

Developed by Jef Poskanzer as part of the Netpbm project in the early 1990s. Netpbm originated from the PBMPLUS package (1988) and evolved into a standard for portable image formats on Unix systems.

SEE ALSO

ppmtobmp(1), anytopnm(1), pnmtopnm(1), ppm(5)

Copied to clipboard