bmptopnm
Convert BMP images to PNM format
TLDR
Generate the PBM, PGM, or PNM image as output, for Windows or OS/2 BMP file as input
Report contents of the BMP header to stderr
Display version
SYNOPSIS
bmptopnm [-verbose] [-windows|-os2] [bmpfile]
PARAMETERS
-verbose
Print processing information about the input file to stderr.
-windows
Interpret input as Windows BMP format (default).
-os2
Interpret input as OS/2 BMP format.
DESCRIPTION
bmptopnm is a utility from the Netpbm graphics suite that reads Microsoft Windows BMP (Bitmap) files and converts them to PNM (Portable Anymap) format, which includes PBM (bitmap), PGM (grayscale), or PPM (pixmap) depending on the image depth.
It handles BMP Versions 2 and 3, supporting 1-bit monochrome, 4-bit and 8-bit paletted, and 24-bit RGB images. For paletted BMPs, it generates a PPM by approximating colors from the palette. The tool automatically detects and decompresses RLE-compressed data when possible.
Input is read from a file or standard input, with output to standard output, enabling easy integration into pipelines for further processing with other Netpbm tools. It distinguishes between Windows and OS/2 BMP variants via options, ensuring compatibility with different file flavors.
Primarily used in batch conversions, scripting, or when BMP support is needed in PNM-based workflows, bmptopnm provides lossless conversion where possible, though palette approximation may introduce minor color differences.
CAVEATS
Supports only BMP V2/V3; ignores V4+ features like alpha channels. Limited RLE support; may fail on exotic compression. Palette approximation can cause color shifts. No multi-image BMP support.
OUTPUT SELECTION
Produces PBM for 1-bit, PGM for 8-bit grayscale, PPM for color/paletted images.
EXAMPLE
bmptopnm -verbose image.bmp > image.ppm
Convert with details to PPM.
HISTORY
Part of Netpbm (formerly PBMPLUS), developed by Jef Poskanzer starting ~1991. Evolved with Netpbm releases for improved BMP handling; stable since early 2000s.


