pnm
Manipulate Netpbm image files
SYNOPSIS
As a standalone command, pnm does not exist. It's an umbrella term referring to the family of Netpbm utilities that operate on PNM and other image formats.
Most Netpbm commands follow a general structure:
command_name [options] [input_file] > [output_file]
For example, to convert a PNG to PNM format and then scale it:
pngtopnm input.png | pnmscale -xsize 100 > output.pnm
PARAMETERS
General Netpbm Parameters (varies per utility)
Parameters are highly specific to each individual Netpbm utility. There is no universal set of parameters for 'pnm'. However, common types of parameters found across the suite include:
-xsize, -ysize
Used by scaling utilities like pnmscale to specify output dimensions.
-width, -height
Similar to x/ysize, for specifying exact output dimensions.
-verbose
Prints informational messages during processing (common in many commands, e.g., anytopnm converters).
-plain
Outputs the 'plain' (ASCII) version of the PNM format, rather than the default raw (binary) version, for utilities that generate PNM.
input_file
The path to the input image file. If omitted, input is read from standard input (stdin), which is crucial for piping.
output_file
The path for the output image file. If omitted, output is written to standard output (stdout), allowing for chaining commands.
DESCRIPTION
The term pnm most commonly refers to the Portable Anymap format family, which includes PBM (Portable BitMap for black and white images), PGM (Portable GrayMap for grayscale images), and PPM (Portable PixMap for color images).
More broadly, it often denotes the Netpbm project, an extensive suite of command-line utilities designed for manipulating these and other image formats. Netpbm tools are known for their simplicity, flexibility, and ability to be chained together using pipes, making them powerful for scripting complex image processing tasks. Each utility typically performs a single, well-defined operation, such as scaling, cropping, converting formats, or applying filters.
CAVEATS
The primary caveat is that pnm is not a single executable command in Linux. It is an umbrella term referring to the Portable Anymap image formats (PBM, PGM, PPM) and the vast collection of Netpbm command-line utilities that operate on these formats. Users should refer to specific Netpbm utility man pages (e.g., man pnmscale, man jpegtopnm) for detailed usage and options, as parameters are highly command-specific.
PNM FILE FORMATS
The PNM family of formats includes PBM (Portable BitMap, monochrome), PGM (Portable GrayMap, grayscale), and PPM (Portable PixMap, color). These are exceedingly simple, raw image formats often used as an intermediary for conversion between other image types due to their ease of parsing and generation. Both 'raw' (binary) and 'plain' (ASCII) versions exist, with binary being more efficient for storage and ASCII useful for debugging or simple text manipulation.
UNIX PHILOSOPHY
The Netpbm suite perfectly embodies the Unix philosophy: 'Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.' This design allows users to combine multiple Netpbm tools using pipes (`|`) to create complex image processing pipelines, rather than relying on a single monolithic application.
HISTORY
The Netpbm suite, which defines and operates on the PNM formats, originated from the Pbmplus package, developed by Jef Poskanzer in the late 1980s. Pbmplus was designed to be a simple, modular set of tools for converting and manipulating images, emphasizing the Unix philosophy of small tools doing one thing well and connecting via pipes. Over time, it evolved into Netpbm, incorporating a wider range of image formats and utilities, while retaining its core principles of simplicity and modularity. Its development continues to be community-driven, making it a robust and widely used toolkit in scripting and command-line image processing.