pbmtopng
Convert PBM image to PNG image
SYNOPSIS
pbmtopng [-verbose] [-compression N] [-interlace] [-transparent] [-gamma N] [-text text] [-time] [-comment text] [-sRGB] [pbmfile]
Alternatively, commonly used with pipes:
any_image_command | pbmtopng [options] > output.png
PARAMETERS
-verbose
Prints diagnostic information about the conversion process to standard error.
-compression N
Sets the PNG compression level, where N is an integer from 0 (no compression) to 9 (maximum compression). The default is typically 6.
-interlace
Enables Adam7 interlacing, which allows an image to be progressively displayed as it downloads.
-transparent
Makes the 'white' pixels (foreground in PBM) transparent in the output PNG image. Only applicable to monochrome PBM input.
-gamma N
Embeds a gamma correction value (N) into the PNG, influencing how the image's brightness is displayed.
-text text
Embeds a generic text string into the PNG. Can be used multiple times for different text chunks (e.g., title, author).
-time
Embeds the current time and date into the PNG file's tIME chunk.
-comment text
Embeds a comment string into the PNG file.
-sRGB
Embeds an sRGB (standard Red Green Blue) color space chunk into the PNG, promoting consistent color rendering.
DESCRIPTION
The pbmtopng command is a fundamental utility within the Netpbm image manipulation suite. It specializes in converting images from the Portable BitMap (PBM) format to the Portable Network Graphics (PNG) format. PBM is a very simple, monochrome (black and white) image format, and pbmtopng efficiently transforms this 1-bit per pixel data into the more widely supported and feature-rich PNG standard.
Typically, pbmtopng reads a PBM image from its standard input and writes the resulting PNG image to its standard output, making it ideal for use in command-line pipelines. This allows users to chain operations, for example, converting a different image format to PBM first (e.g., using ppmtopbm or pgmtopbm) and then piping the output directly to pbmtopng. The command provides options to control PNG-specific features like compression level, interlacing, transparency (for one of the monochrome colors), and embedding metadata.
CAVEATS
pbmtopng strictly expects a PBM (Portable BitMap) image as input. If your image is in another Netpbm format (PGM for grayscale, PPM for color), you must first convert it to PBM using commands like pgmtopbm or ppmtopbm before piping it to pbmtopng. Due to PBM's monochrome nature, the -transparent option only applies to one of the two colors (usually the 'white' background).
STANDARD INPUT/OUTPUT USAGE
pbmtopng is designed to operate seamlessly with standard input and output. This allows it to be easily integrated into shell scripts and command pipelines. For example, to convert a PPM image to PBM and then to PNG, you would use: ppmtopbm image.ppm | pbmtopng > image.png. When an input file is specified as an argument, it reads from that file instead of standard input.
HISTORY
pbmtopng is part of the Netpbm project, a comprehensive set of graphics tools developed by Jef Poskanzer starting in the early 1980s. Netpbm emerged from the earlier 'pbmplus' package. The suite is known for its simple, pipe-friendly design, where each tool performs a single, well-defined image manipulation task. pbmtopng was developed as part of this evolution to integrate PNG support into the ecosystem, maintaining Netpbm's modular philosophy.