LinuxCommandLibrary

pgmmake

Create a portable graymap image

TLDR

Create PGM image with a uniform gray level (specified as a number between 0 and 1) and the specified dimensions

$ pgmmake [graylevel] [width] [height] > [path/to/output_file.pgm]
copy

SYNOPSIS

pgmmake width height value [pgmfile]

PARAMETERS

width
    Image width in pixels (positive integer)

height
    Image height in pixels (positive integer)

value
    Uniform gray value (integer 0-255)

pgmfile
    Optional output filename (defaults to stdout)

DESCRIPTION

pgmmake is a utility from the Netpbm graphics toolkit for generating rectangular PGM (Portable Graymap) images filled with a single uniform gray value. It is ideal for creating solid gray test patterns, backgrounds, masks, or synthetic images for image processing, computer vision, or graphics testing.

Specify the image dimensions in pixels (width and height) and a gray intensity value ranging from 0 (black) to 255 (white). The tool outputs a binary PGM file (magic number P5) to standard output by default, which can be redirected to a file. The maximum gray value (maxval) is fixed at 255.

This simple generator integrates seamlessly with other Netpbm tools for batch processing, filtering, or conversion to formats like PNG or JPEG via pnmtopng or similar. It supports arbitrary sizes limited only by system memory.

CAVEATS

Width and height must be positive integers; value clamped to 0-255. Large images may consume significant memory. Outputs binary PGM (P5); use pnmnoraw for plain (ASCII) format.

EXAMPLE

pgmmake 640 480 128 > midgray.pgm
Generates a 640x480 mid-gray (50%) image.

MAX SIZE

No hardcoded limit; constrained by available RAM (each pixel = 1 byte).

HISTORY

Originated in Jef Poskanzer's PBMPLUS package (1988); evolved into modern Netpbm suite with portable PNM formats.

SEE ALSO

ppmmake(1), pbmmake(1), pgm(5), pnm(5)

Copied to clipboard