LinuxCommandLibrary

ppmquant

Reduce PPM image color count

TLDR

Reduce to N colors

$ ppmquant [256] [input.ppm] > [output.ppm]
copy
Reduce to 16 colors
$ ppmquant [16] [input.ppm] > [output.ppm]
copy
With Floyd-Steinberg dithering
$ ppmquant -fs [256] [input.ppm] > [output.ppm]
copy
Use existing colormap
$ ppmquant -map [palette.ppm] [input.ppm] > [output.ppm]
copy

SYNOPSIS

ppmquant [options] ncolors [ppmfile]

DESCRIPTION

ppmquant reduces the number of colors in a PPM image using median-cut quantization. Essential for creating GIF images or reducing file size.
Superseded by pnmquant in modern Netpbm.

PARAMETERS

ncolors

Maximum number of colors.
-fs
Floyd-Steinberg dithering.
-map file
Use colormap from file.
-spreadbrightness
Spread by brightness.
-spreadluminosity
Spread by luminosity.

EXAMPLES

$ # Reduce to 256 colors
ppmquant 256 photo.ppm > reduced.ppm

# 16 colors with dithering
ppmquant -fs 16 image.ppm > dithered.ppm

# Use web-safe palette
ppmquant -map websafe.ppm image.ppm > websafe.ppm

# Convert for GIF
ppmquant 256 image.ppm | ppmtogif > image.gif
copy

CAVEATS

Use pnmquant for new work. Dithering can increase file size. Part of Netpbm.

HISTORY

ppmquant is part of Netpbm by Jef Poskanzer, implementing the median-cut color quantization algorithm by Paul Heckbert.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community