LinuxCommandLibrary

anytopnm

Convert various image formats to PNM/PBM/PGM/PPM

TLDR

Convert an input image to PBM, PGM, or PPM format irrespective of the input type

$ anytopnm [path/to/input] > [path/to/output.pnm]
copy

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

SYNOPSIS

anytopnm [options] [inputfile ...]

PARAMETERS

-verbose
    Enable verbose output from underlying filters, reporting what anytopnm is trying.

-quiet
    Suppress non-error output from underlying filters.

-debug
    Print debugging information about the conversion process.

-list
    List the sequence of filters anytopnm would try, without processing files.

-trial
    Test filters and report which succeeds first, but produce no output image.

-version
    Print the Netpbm version and exit.

DESCRIPTION

anytopnm is a versatile utility from the Netpbm graphics toolkit that converts images in various formats to Portable Anymap (PNM), which encompasses PBM (bitmap), PGM (grayscale), and PPM (color pixmap). It achieves this by sequentially attempting a predefined list of Netpbm input filters (e.g., giftopnm, pngtopnm, jpegtopnm, tifftopnm) on the input until one successfully recognizes and converts the file.

Input is read from standard input if no files are specified, or from one or more named files. Output is always PNM to standard output, making it ideal for piping into other tools. This approach handles dozens of formats without needing to know the input type upfront, useful in scripts or batch processing where file types vary.

Developed for Unix-like systems, it prioritizes speed by ordering common formats first but may require the full Netpbm suite installed for all supported formats.

CAVEATS

Conversion order is fixed and may misidentify ambiguous formats; process can be slow if early filters fail on large files. Requires Netpbm loaders for specific formats.

FILTER TRIAL ORDER

Tries filters in this rough order: pnm, xbmtopbm, pbmtext, pbmmask, ... pngtopnm, giftopnm, jpegtopnm, etc. Full list via anytopnm -list.

HISTORY

Part of the Netpbm project, initiated by Jef Poskanzer in 1988. anytopnm was introduced later to simplify handling diverse image formats, with ongoing updates in Netpbm releases to add new filters and improve efficiency.

SEE ALSO

pnm(5), giftopnm(1), pngtopnm(1), jpegtopnm(1), tifftopnm(1), netpbm(1)

Copied to clipboard