# man > pnmquant(1)

> **TLDR:** Quantize the colors in a PNM image into a smaller set.
>
- 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}}`

*Source: tldr-pages*

---

[pnmquant(1)](https://www.chedong.com/phpMan.php/man/pnmquant/1/markdown)                            General Commands Manual                           [pnmquant(1)](https://www.chedong.com/phpMan.php/man/pnmquant/1/markdown)



## NAME
       pnmquant - quantize the colors in a Netpbm image to a smaller set


## SYNOPSIS
       **pnmquant**   [**-center**|**-meancolor**|**-meanpixel**]   [**-floyd**|**-fs**]   [**-nofloyd**|**-nofs**]  [**-spreadbright**‐‐
       **ness**|**-spreadluminosity**] _ncolors_ [_pnmfile_]

       All options can be abbreviated to their shortest unique prefix.  You may use two hyphens  in‐
       stead  of one to designate an option.  You may use either white space or equals signs between
       an option name and its value.


## DESCRIPTION
       Reads a PNM image as input.  Chooses _ncolors_ colors to best represent the image, maps the ex‐
       isting colors to the new ones, and writes a PNM image as output.

       This program is simply a combination of **pnmcolormap** and **pnmremap**, where the colors of the in‐
       put are remapped using a color map which is generated from the colors  in  that  same  input.
       The  options  have  the same meaning as in those programs.  See their documentation to under‐
       stand **pnmquant**.

       It is much faster to call **pnmcolormap** and **pnmremap** directly than to run  **pnmquant**.   **pnmquant**
       is just a convenience.

       **ppmquant**  is  an older program which does the same thing as **pnmquant**, but on only PPM images.
       It is, however, faster than either **pnmquant** or **ppmcolormap**/**pnmremap**.


## SEE ALSO
       [**pnmcolormap**(1)](https://www.chedong.com/phpMan.php/man/pnmcolormap/1/markdown), [**pnmremap**(1)](https://www.chedong.com/phpMan.php/man/pnmremap/1/markdown), [**ppmquantall**(1)](https://www.chedong.com/phpMan.php/man/ppmquantall/1/markdown), [**pnmdepth**(1)](https://www.chedong.com/phpMan.php/man/pnmdepth/1/markdown), [**ppmdither**(1)](https://www.chedong.com/phpMan.php/man/ppmdither/1/markdown), [**ppmquant**(1)](https://www.chedong.com/phpMan.php/man/ppmquant/1/markdown), [**pnm**(5)](https://www.chedong.com/phpMan.php/man/pnm/5/markdown)


## AUTHOR
       Written by Bryan Henderson



                                           20 January 2002                               [pnmquant(1)](https://www.chedong.com/phpMan.php/man/pnmquant/1/markdown)
