LinuxCommandLibrary

imgtoppm

Convert image formats to PPM

TLDR

Convert an input image to PPM format

$ imgtoppm [path/to/input] > [path/to/output.ppm]
copy

Display version
$ imgtoppm [[-v|-version]]
copy

SYNOPSIS

imgtoppm [-verbose] [imgfile]

PARAMETERS

-verbose
    Prints details about the IMG file (size, depth, etc.) to stderr.

imgfile
    Input IMG file; if absent, reads from stdin.

DESCRIPTION

imgtoppm is a utility from the Netpbm graphics package that converts raster images in the GEM IMG format to PPM (Portable Pixmap) format. The IMG format originated with Digital Research's GEM software suite and was widely used by Ventura Publisher for desktop publishing on early PCs.

IMG files are typically grayscale, supporting depths of 1 plane (monochrome), 2 planes (4 gray levels), 4 planes (16 gray levels), or 8 planes (256 gray levels). imgtoppm accurately maps these to equivalent PPM images: black-and-white for 1 plane, grayscale PPM for multi-plane files.

The command reads from a file or standard input and writes raw PPM to standard output, enabling easy piping to other tools like pnmtopng or ppmtogif. It's ideal for archiving or processing legacy graphics from DOS-era documents.

With minimal options, imgtoppm emphasizes reliability and simplicity, handling the proprietary header and raster data directly. Output quality preserves the original resolution and density.

CAVEATS

Requires valid IMG header; only supports grayscale depths (1-8 planes). Unsupported formats or corruption may produce blank or incorrect output.
No color support, as IMG is grayscale-only.

SUPPORTED IMG DEPTHS

1 plane: monochrome PBM/PPM
2 planes: 4-level grayscale
4 planes: 16-level grayscale
8 planes: 256-level grayscale

EXAMPLE USAGE

imgtoppm image.img | pnmtopng > image.png
Converts IMG to PNG via PPM pipe.

HISTORY

Part of the Netpbm suite, created by Jef Poskanzer around 1991. Netpbm originated in 1988 as PBMPLUS; imgtoppm added for legacy DOS formats. Remains unchanged in core functionality across Netpbm releases.

SEE ALSO

ppm(5), pbm(5), pgm(5), netpbm(1), xbmtoppm(1), macptoppm(1)

Copied to clipboard