LinuxCommandLibrary

ppmrainbow

Create a rainbow-colored Portable Pixmap image

TLDR

Generate a rainbow consisting of the specified colors

$ ppmrainbow [color1 color2 ...] > [path/to/output_file.ppm]
copy

Specify the size of the output in pixels
$ ppmrainbow [[-w|-width]] [width] [[-h|-height]] [height] [color1 color2 ...] > [path/to/output_file.ppm]
copy

End the rainbow with the last color specified, do not repeat the first color
$ ppmrainbow [[-n|-norepeat]] [color1 color2 ...] > [path/to/output_file.ppm]
copy

SYNOPSIS

ppmrainbow [-leftcolor color] [-rightcolor color] [-xsize cols]
[-ysize rows] [-xvariance factor] [-yvariance factor]
[-rgb] [-maxval maxval]

PARAMETERS

-leftcolor color
    Sets the RGB color for the left side (or start) of the image. Color is specified as 'R,G,B' values. Default is '255,0,0' (red).

-rightcolor color
    Sets the RGB color for the right side (or end) of the image. Color is specified as 'R,G,B' values. Default is '128,0,255' (violet).

-xsize cols
    Specifies the width of the image in columns (pixels). Default is 256.

-ysize rows
    Specifies the height of the image in rows (pixels). Default is 256.

-xvariance factor
    Controls the non-linear variation of color along the X-axis. A factor of 1 is linear. Values greater than 1 speed up variation at the start, less than 1 slow it down. Default is 1.

-yvariance factor
    Controls the non-linear variation of color along the Y-axis. A factor of 0 means no Y-axis variation. Default is 0.

-rgb
    Forces color interpolation to occur in RGB color space instead of the default HSV (hue) space.

-maxval maxval
    Defines the maximum color value for pixels in the output PPM image. Default is 255.

DESCRIPTION

The ppmrainbow command is a utility within the Netpbm toolkit, designed to generate a Portable Pixmap (PPM) format image depicting a smooth color spectrum, commonly referred to as a rainbow. By default, it creates an image that transitions from red on the left to violet on the right, simulating the visible light spectrum. Users have extensive control over the generated image through various options. They can specify the exact RGB colors for the left and right (and implicitly top/bottom) edges of the spectrum, define the image dimensions (width and height), and adjust the non-linear progression of the color variation along both the X and Y axes using variance factors. Additionally, it offers a choice between interpolating colors in HSV (hue) space, which is the default for a more natural rainbow effect, or a linear interpolation in RGB color space. This flexibility makes it useful for creating custom color gradients for various graphical applications.

CAVEATS

The variance calculation might produce unexpected or less intuitive results, especially when using extreme factor values or certain complex color combinations for the start and end points.

OUTPUT FORMAT

The command outputs a Portable Pixmap (PPM) format image to standard output. This output can be redirected to a file, for example:
ppmrainbow -xsize 512 -ysize 200 > myrainbow.ppm

COLOR SPECIFICATION

Colors for -leftcolor and -rightcolor options should be provided as comma-separated RGB integer values (e.g., '255,0,0' for red). By default, these values range from 0 to 255, but this range can be altered using the -maxval option.

HISTORY

ppmrainbow is a component of the Netpbm project, a comprehensive toolkit for manipulating graphic images. Its development aligns with Netpbm's goal of providing modular and composable image processing utilities, with its initial release and evolution tied to the broader Netpbm codebase.

SEE ALSO

ppm(5), netpbm(1)

Copied to clipboard