LinuxCommandLibrary

pamtopam

Convert between PAM (portable anymap) image formats

TLDR

Copy a PAM image (i.e. a PBM, PGM, PPM or PAM image) from stdin to stdout

$ pamtopam < [path/to/image.pam] > [path/to/output.pam]
copy

Display version
$ pamtopam [[-v|-version]]
copy

SYNOPSIS

pamtopam [netpbmfile] [-alphaok] [-alphanotok] [-bytedepth] [-check] [-depth=depth] [-noalphaplain] [-plain] [-tupletype=tupletype] [-verbose]
The input file is read from standard input if not specified, and output is written to standard output.

PARAMETERS

-alphaok
    If the input has an alpha channel, preserve it. If not, add a full-opacity alpha channel to the output.

-alphanotok
    If the input has an alpha channel, remove it from the output. If it doesn't, do nothing.

-bytedepth
    Forces the output image's depth (maxval) to be a multiple of 8 bits, converting if necessary.

-check
    Performs consistency checks on the input and output data during processing.

-depth=depth
    Sets the maximum pixel value (maxval) for the output PAM image to the specified depth.

-noalphaplain
    Writes the output in plain (ASCII) format, but only if no alpha channel is present in the image.

-plain
    Forces the output to be in plain (ASCII) format, which is human-readable but larger than raw format.

-tupletype=tupletype
    Sets the tuple type of the output PAM image to tupletype (e.g., "RGB", "GRAYSCALE", "RGB_ALPHA", "BLACKANDWHITE").

-verbose
    Prints informative messages about the processing steps to standard error.

DESCRIPTION

pamtopam is a Netpbm program that reads an image in any of the Netpbm formats (PBM, PGM, PPM, or PAM) and writes it out in the PAM (Portable Arbitrary Map) format. Its primary use is to ensure an image is in the versatile PAM format, which supports arbitrary tuple types and depths, making it suitable for more complex image processing operations. It can also be used to change certain properties of an existing PAM image, such as its depth or tuple type, or to normalize its representation. For example, it can convert a PBM (monochrome) or PPM (color) image into a PAM image, preserving or modifying aspects like transparency channels or color depth based on the specified options.

CAVEATS

pamtopam converts to the general PAM format. For specific conversions to PBM, PGM, or PPM, consider using anytopnm.
Using the -depth option to decrease depth can lead to loss of image precision. Conversely, increasing depth does not add more information but can increase file size.
The -plain option results in significantly larger output files compared to the default raw format, especially for large images.

STANDARD INPUT/OUTPUT

pamtopam typically reads its input image from standard input if no file argument is provided, and writes the resulting PAM image to standard output. This design allows it to be easily integrated into pipelines with other Netpbm tools or standard Unix commands for chained image processing.

PAM FORMAT VERSATILITY

The Portable Arbitrary Map (PAM) format is designed to be highly flexible, supporting various pixel depths (bits per sample) and tuple types (e.g., grayscale, RGB, RGB with alpha, CMYK, etc.). pamtopam leverages this versatility by allowing users to specify desired output characteristics, making it a foundational tool for complex Netpbm image operations.

HISTORY

pamtopam is a component of the Netpbm package, a suite of graphics utilities dating back to the late 1980s. The PAM (Portable Arbitrary Map) format itself was introduced later in Netpbm's development to provide a more flexible and extensible image format compared to the older PBM, PGM, and PPM formats, which were limited in their support for different pixel depths, tuple types (e.g., transparency), and arbitrary data. pamtopam was developed to facilitate conversions into and manipulations of this newer, more versatile PAM format.

SEE ALSO

anytopnm(1), pam(5), pnm(5), pbmtoppm(1), pnmscale(1), pamfile(1)

Copied to clipboard