pgmramp
Create grayscale gradient Portable Graymap image
TLDR
Generate a left-to-right greyscale map
Generate a top-to-bottom greyscale map
Generate a rectangular greyscale map
Generate a elliptical greyscale map
Generate a greyscale map from the top-left corner to the bottom-right corner
SYNOPSIS
pgmramp [maxval]
PARAMETERS
maxval
Optional integer specifying the maximum gray value (0-65535). Default is 255. Sets image height to maxval + 1 pixels; width is always 1 pixel.
DESCRIPTION
The pgmramp command is a simple utility from the Netpbm graphics toolkit that produces a portable grayscale map (PGM) image consisting of a vertical ramp of gray shades. It outputs a 1-pixel-wide image where the height is maxval + 1 pixels. The top pixel is black (gray value 0), and the gray level increases linearly to full white (gray value maxval) at the bottom.
This tool is ideal for creating test patterns used in image processing, display calibration, or as a reference for grayscale gradients. The output is in raw PGM format (magic number P5) sent to standard output, which can be redirected to a file or piped to other Netpbm tools for further manipulation, such as resizing or format conversion.
For example, running pgmramp without arguments generates a standard 256-pixel-high (0-255) ramp, perfect for 8-bit grayscale testing. It's lightweight and fast, making it useful in scripts for generating consistent test images across systems.
CAVEATS
Image is fixed at 1 pixel wide; use pamfunc or pnmscale for wider ramps. No color support (grayscale only). Large maxval values produce very tall images.
EXAMPLE USAGE
pgmramp 255 > ramp.pgm
Creates 256-pixel-high grayscale ramp.
pgmramp 65535 | pnmscale -xysize 100 1000 | pnmtopng > wide_ramp.png
Generates wide ramp and converts to PNG.
OUTPUT FORMAT
Always P5 (binary PGM) to stdout. Header: P5
# width 1
# height maxval+1
# max gray value maxval
followed by pixel data.
HISTORY
Part of the Netpbm suite, originally developed by Jef Poskanzer in 1988 as part of PBMPLUS for early Unix image processing. Evolved through Netpbm releases; remains unchanged in core functionality for compatibility.


