summary refs log tree commit diff
path: root/pnmquant.html
blob: 516875c1f38f4046a9f11370e90c3f71fe6eb559 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pnmquant User Manual</title></head>
<body>
<h1>pnmquant</h1>
Updated: 09 February 2019
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>
pnmquant - quantize the colors in a Netpbm image to a smaller set

<h2 id="synopsis">SYNOPSIS</h2>

<b>pnmquant</b>
[<b>-center</b>|<b>-meancolor</b>|<b>-meanpixel</b>]
[<b>-floyd</b>|<b>-fs</b>]
[<b>-nofloyd</b>|<b>-nofs</b>]
[<b>-spreadbrightness</b>|<b>-spreadluminosity</b>]
{[<b>-norandom</b>]|[<b>-randomseed=</b><i>n</i>]}
<i>ncolors</i> [<i>pnmfile</i>]

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


<h2 id="description">DESCRIPTION</h2>

<p>This program is part of <a href="index.html">Netpbm</a>.

<p><b>pnmquant</b> reads a PNM image as input.  It chooses <i>ncolors</i>
colors to best represent the image, maps the existing colors
to the new ones, and writes a PNM image as output.

<p>This program is simply a combination of <b>pnmcolormap</b> and
<b>pnmremap</b>, where the colors of the input 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 understand <b>pnmquant</b>.

<p>You may actually get fewer than <b>ncolors</b> colors in the output because
  the method <b>pnmcolormap</b> uses to choose the best set of colors for the
  image is not the same as the method <b>pnmremap</b> uses to determine the
  best color from the set to represent an individual color.  For example,
  <b>pnmcolormap</b> may include salmon in the color map as the best
  representative of a pink pixel in the input and include coral in the color
  map as the best representative of an actual coral pixel in the input.  But
  <b>pnmremap</b> is free to use any color in the color map to represent that
  pink pixel and would find coral is a closer match for pink than salmon and
  therefore use coral for pink.  <b>pnmremap</b> might not use salmon
  for <em>any</em> pixel.

<p>This waste of a slot in the color map is a consequence of the approximate
  method <b>pnmcolormap</b> uses in order to compute the color map with a
  practical amount of computation.


<h3 id="separate">Running <b>pnmcolormap</b> and <b>pnmremap</b> Separately
</h3>

<p>It is much faster to call <b>pnmcolormap</b> and <b>pnmremap</b>
directly than to run <b>pnmquant</b>.  You save the overhead of the
Perl interpreter and creating two extra processes.  <b>pnmquant</b> is
just a convenience.

<p>Here is an example of the relationship between the programs:

<p>This:

<pre>
<kbd>
    $ pnmquant 256 myimage.pnm &gt;/tmp/colormap.pnm &gt;myimage256.pnm
</kbd>
</pre>

<p>does essentially this:

<pre>
<kbd>
    $ pnmcolormap 256 myimage.pnm &gt;/tmp/colormap.pnm
    $ pnmremap -mapfile=/tmp/colormap.pnm myimage.pnm &gt;myimage256.pnm
</kbd>
</pre>

<h2 id="options">OPTIONS</h2>

<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pnmquant</b> recognizes the following
command line options:

<h3 id="pnmcolormapopt">Options Passed to <b>pnmcolormap</b></h3>

  <p>These options control the selection of the palette.  They are options to
  <a href="pnmcolormap.html"><b>pnmcolormap</b></a>.

<dl compact>
<dt><b>-center</b>
<dt><b>-meancolor</b>
<dt><b>-meanpixel</b>
<dt><b>-spreadbrightness</b>
<dt><b>-spreadluminosity</b>
</dl>

<h3 id="pnmremapopt">Options Passed to <b>pnmremap</b></h3>

  <p>These options control which color from the palette the program uses to
  replace a pixel of a certain color from the input.  They are options to
  <a href="pnmremap.html"><b>pnmremap</b></a>.

<dl compact>
<dt><b>-floyd</b>
<dt><b>-fs</b>
<dt><b>-nofloyd</b>
<dt><b>-nofs</b>
<dt><b>-norandom</b>
<dt><b>-randomseed</b>
<dt><b>-norandom</b>
</dl>

<h2 id="history">HISTORY</h2>

<p><b>pnmquant</b> did not exist before Netpbm 9.21 (January 2001).
Before that, <b>ppmquant</b> did the same thing, but only on PPM
images.  <b>ppmquant</b> continues to exist, but is only a front end
(for name compatibility) to <b>pnmquant</b>.

<p><b>-version</b> did not exist before Netpbm 10.75 (June 2016).
  
<p><b>-norandom</b> did not exist before Netpbm 10.82 (March 2018).
  
<h2 id="seealso">SEE ALSO</h2>

<b><a href="pnmcolormap.html">pnmcolormap</a></b>,
<b><a href="pnmremap.html">pnmremap</a></b>,
<b><a href="pnmquantall.html">pnmquantall</a></b>,
<b><a href="pamdepth.html">pamdepth</a></b>,
<b><a href="ppmdither.html">ppmdither</a></b>,
<b><a href="ppmquant.html">ppmquant</a></b>,
<b><a href="pnm.html">pnm</a></b>

<hr>
<h2 id="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
  <ul>
  <li><a href="#separate">Running pnmcolormap and pnmremap Separately</a>
  </ul>
<li><a href="#options">OPTIONS</a>
  <ul>
  <li><a href="#pnmcolormapopt">Options Passed to pnmcolormap</a>
  <li><a href="#pnmremapopt">Options Passed to pnmremap</a>
  </ul>
<li><a href="#history">HISTORY</a>
<li><a href="#seealso">SEE ALSO</a>
</ul>
</body>
</html>