Linux command
pnmquant 命令
文本
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Reduce colors
pnmquant [256] [input.pnm] > [output.pnm]
Use center-of-box color selection
pnmquant -center [16] [input.pnm] > [output.pnm]
Apply Floyd-Steinberg dithering
pnmquant -floyd [256] [input.pnm] > [output.pnm]
Quantize to a predefined colormap
pnmquant -mapfile [mapfile.pnm] [256] [input.pnm] > [output.pnm]
说明
pnmquant reduces the number of colors in a PNM image to a specified count using the median-cut color quantization algorithm. This is useful for preparing images for formats with limited color palettes or for reducing file size. The -floyd option enables Floyd-Steinberg dithering to simulate more colors by distributing quantization error to neighboring pixels. The -mapfile option allows quantizing to a pre-defined color palette from another image. Part of the Netpbm toolkit; this is a wrapper script that calls pnmcolormap and pnmremap internally.
参数
- -floyd, -fs
- Enable Floyd-Steinberg dithering to improve visual quality.
- -nofloyd, -nofs
- Disable dithering (default).
- -center
- Choose the center of each color box as the representative color.
- -meancolor
- Choose the mean of all colors in each box (default).
- -meanpixel
- Choose the mean weighted by pixel count in each box.
- -spreadbrightness
- Spread boxes based on brightness range rather than color population.
- -spreadluminosity
- Spread boxes based on luminosity range.
- -mapfile _file_
- Quantize to a predefined colormap from file.
FAQ
What is the pnmquant command used for?
pnmquant reduces the number of colors in a PNM image to a specified count using the median-cut color quantization algorithm. This is useful for preparing images for formats with limited color palettes or for reducing file size. The -floyd option enables Floyd-Steinberg dithering to simulate more colors by distributing quantization error to neighboring pixels. The -mapfile option allows quantizing to a pre-defined color palette from another image. Part of the Netpbm toolkit; this is a wrapper script that calls pnmcolormap and pnmremap internally.
How do I run a basic pnmquant example?
Run `pnmquant [256] [input.pnm] > [output.pnm]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -floyd, -fs do in pnmquant?
Enable Floyd-Steinberg dithering to improve visual quality.