LinuxCommandLibrary

pnmcolormap

Generate color palette from PNM images

TLDR

Generate color map with N colors

$ pnmcolormap [256] [image.ppm] > [colormap.ppm]
copy
Use median cut algorithm
$ pnmcolormap -center [16] [image.ppm] > [colormap.ppm]
copy
Spread colors evenly
$ pnmcolormap -spreadluminosity [256] [image.ppm] > [colormap.ppm]
copy
From multiple images
$ pnmcolormap [256] [image1.ppm] [image2.ppm] > [colormap.ppm]
copy

SYNOPSIS

pnmcolormap [options] ncolors [pnmfile...]

DESCRIPTION

pnmcolormap creates a color map (palette) from an image using median cut quantization. The output is a small image where each pixel is a color from the palette.
Used with pnmremap for color reduction.

PARAMETERS

ncolors

Maximum colors in map.
-center
Use center of cluster.
-meancolor
Use mean color of cluster.
-meanpixel
Use mean weighted by pixel count.
-spreadbrightness
Spread by brightness.
-spreadluminosity
Spread by luminosity.

EXAMPLES

$ # Create 256-color palette
pnmcolormap 256 photo.ppm > palette.ppm

# Reduce colors using map
pnmcolormap 16 image.ppm > map.ppm
pnmremap -mapfile=map.ppm image.ppm > reduced.ppm

# Combined color reduction
pnmcolormap 256 image.ppm | pnmremap -mapfile=- image.ppm > reduced.ppm
copy

CAVEATS

Output is the colormap, not the remapped image. Use pnmremap to apply. Part of Netpbm.

HISTORY

pnmcolormap is part of Netpbm, implementing median-cut color quantization algorithm.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community