pgm
Process Portable Graymap images
SYNOPSIS
'pgm' is not a standalone command.
Instead, functionality related to the Portable Graymap (PGM) format is provided by various utilities within the Netpbm suite. These tools typically follow a pattern like:
[utility_name] [options] [input_file] > [output_file]
Examples include anytopnm (converts various formats to PGM/PPM/PBM), pgmtoppm (converts PGM to PPM), ppmtogray (converts PPM to PGM), and many others. Each utility has its own specific syntax and options.
PARAMETERS
N/A
As 'pgm' is not a standalone command, it does not have its own set of direct parameters. Parameters are specific to each individual utility within the Netpbm suite that operates on PGM files. Common options often relate to image dimensions, verbosity, or file handling modes, and vary widely per utility.
DESCRIPTION
The term 'pgm' in a Linux context primarily refers to the Portable Graymap image file format, not a single standalone command-line utility. PGM is a simple, grayscale image format that is part of the Netpbm suite of graphics utilities. It can store images in either ASCII (plain text) or binary format. Due to its simplicity, PGM is often used as an intermediary format by other image conversion tools. While there isn't a direct 'pgm' command, a collection of powerful utilities within the Netpbm package are specifically designed to create, convert, and manipulate PGM files, often alongside PPM (Portable Pixmap) and PBM (Portable Bitmap) formats. These utilities operate via standard input and output, making them highly scriptable and versatile for image processing tasks.
CAVEATS
It is important to clarify that 'pgm' is not a standalone executable command in the typical Linux sense (like ls or grep). When people refer to 'pgm' functionality, they are almost universally referring to operations on the Portable Graymap image format, typically performed using tools from the Netpbm collection. Attempting to execute pgm directly on a standard system will likely result in a 'command not found' error. Users should look for specific Netpbm utilities like pgmtoppm, anytopnm, ppmtogray, etc., to perform PGM-related tasks.
KEY NETPBM UTILITIES FOR PGM
The Netpbm suite provides numerous utilities relevant to PGM files. Some commonly used ones include:
anytopnm: Converts many image formats (e.g., JPEG, PNG) into a Netpbm format (PBM, PGM, or PPM).
pgmtoppm: Converts a PGM image to a PPM (Portable Pixmap) image, useful for adding color information or preparing for conversion to other color formats.
ppmtogray: Converts a PPM (color) image to a PGM (grayscale) image.
pnmcrop: Crops an image to its actual contents or a specified region.
pnmscale: Scales (resizes) a Netpbm image.
pnminvert: Inverts the colors in a Netpbm image.
pnmrotate: Rotates a Netpbm image.
These tools often work by piping output from one to the input of another, e.g., jpegtopnm image.jpg | pnmscale 0.5 | ppmtogray > image_small_gray.pgm.
HISTORY
The Portable Graymap (PGM) format originated as part of the Portable Anymap (PNM) family within the Netpbm project. Netpbm was initially developed by Jef Poskanzer in the late 1980s and early 1990s as a suite of command-line tools for converting and manipulating various image formats. The design philosophy of PGM, along with PBM and PPM, was simplicity and ease of parsing, making them ideal as intermediary formats for complex image conversions. They are often used in shell scripts to chain multiple image operations. While newer, more complex formats like PNG and JPEG have become ubiquitous, PGM and the Netpbm tools remain highly valued for their robustness, scriptability, and role in fundamental image processing pipelines on Unix-like systems.