pnmtopng

Convert PNM images to PNG format

TLDR

Convert PNM to PNG
$ pnmtopng [input.pnm] > [output.png]
Convert with compression
$ pnmtopng -compression [9] [input.pnm] > [output.png]
Add alpha channel
$ pnmtopng -alpha [alpha.pgm] [input.ppm] > [output.png]
Create interlaced PNG
$ pnmtopng -interlace [input.pnm] > [output.png]

SYNOPSIS

pnmtopng [options] [file]

DESCRIPTION

pnmtopng converts PNM (PBM, PGM, PPM) images to PNG format with lossless compression. It automatically selects the optimal PNG color type based on the input image.The -alpha option attaches a separate PGM file as an alpha transparency channel. The -compression level (0-9) controls the deflate compression effort, and -interlace creates Adam7 interlaced PNGs for progressive display. The -transparent option designates a specific color as fully transparent. Part of the Netpbm toolkit; superseded by pamtopng.

PARAMETERS

-alpha file

Alpha channel file.
-compression n
Compression level (0-9).
-interlace
Create interlaced PNG.
-transparent color
Transparent color.
-gamma value
Gamma value.

INSTALL

sudo apt install netpbm
sudo dnf install netpbm
sudo pacman -S netpbm
sudo apk add netpbm
sudo zypper install netpbm
brew install netpbm
nix profile install nixpkgs#netpbm

SEE ALSO

pngtopnm(1), pamtopng(1)