pamtopng
Convert PAM image format to PNG
TLDR
Convert the specified PAM image to PNG
Mark the specified color as transparent in the output image
Include the text in the specified file as tEXt chunks in the output
Cause the output file to be interlaced in Adam7 format
SYNOPSIS
pamtopng [ options ] [ pamfile ]
Input is from pamfile or standard input if pamfile is not specified. Output is always to standard output.
PARAMETERS
-verbose
Prints informative messages about the conversion process to standard error.
-transparent=color
Specifies a color in the input image to be treated as transparent in the PNG output. The color can be specified as a hexadecimal RGB value (e.g., #RRGGBB, #RRRGGGBBB) or by a color name found in the rgb.txt file.
-gamma=value
Sets the gamma value for the PNG image. This value is included in the PNG's gAMA chunk. The default gamma value used is 2.2.
-text
This option is provided for compatibility with pnmtopng but has no effect in pamtopng, as it does not have facilities to set text chunks within the PNG file. For adding text chunks, consider using pnmtopng instead.
-alpha
Forces the output PNG to include an alpha channel. If the input PAM image does not inherently have an alpha channel, an opaque alpha channel will be added.
-background=color
Sets the background color for transparent pixels in the PNG image, which is stored in the PNG's bKGD chunk. The color format is the same as for the -transparent option.
-compression=level
Defines the Zlib compression level used for the PNG data, ranging from 0 (no compression) to 9 (maximum compression). The default level is typically determined by the libpng library, often 6.
-interlace
Creates an interlaced PNG image using the Adam7 algorithm. Interlaced PNGs can be displayed progressively as they load.
-force
Forces pamtopng to proceed with operations that it might otherwise consider problematic or inefficient, such as producing a very large indexed PNG or an indexed PNG when input tuple type implies it must be indexed.
DESCRIPTION
pamtopng reads a PAM (Portable Arbitrary Map) image from its input and produces a PNG (Portable Network Graphics) image as output. PAM is the flexible, generalized image format used by the Netpbm image processing tools, capable of representing various pixel types (e.g., RGB, RGBA, grayscale, grayscale with alpha) and arbitrary bit depths.
The command typically reads the PAM input from standard input (or a specified file) and writes the PNG output to standard output, making it suitable for use in shell pipelines. It leverages the underlying libpng library for efficient PNG creation.
While pamtopng can be invoked directly by users, it is often utilized as an intermediary step within larger image manipulation workflows, seamlessly handling different PAM tuple types and 'maxval' (maximum pixel value) to generate appropriate PNG outputs, including proper handling of alpha channels when present in the source PAM data.
CAVEATS
The -text option in pamtopng is a no-op; it does not add text chunks to the PNG. Users requiring text chunks should consider using the pnmtopng command, which offers this functionality.
Since pamtopng writes to standard output, it is almost always used with output redirection (e.g., > output.png) or as part of a pipeline.
PAM FORMAT CONTEXT
PAM (Portable Arbitrary Map) is a highly flexible, generalized image format fundamental to the Netpbm suite. Unlike the simpler PBM, PGM, and PPM formats, PAM can represent any type of pixel (tuple) and bit depth, making it an ideal intermediate format for diverse image processing operations within the Netpbm environment.
STANDARD INPUT/OUTPUT USAGE
By default, pamtopng reads its PAM input from standard input and writes the resulting PNG image to standard output. This design promotes its use in command-line pipelines, allowing it to seamlessly integrate with other Netpbm tools or Unix utilities.