pnmquant
Quantize the colors in a PNM image into a smaller set.
TLDR
Generate an image using only n_colors or less colors as close as possible to the input image
$ pnmquant [n_colors] [path/to/input.pnm] > [path/to/output.pnm]
Generate an image using only n_colors or less colors as close as possible to the input image