1Pnmtopng User Manual(0) Pnmtopng User Manual(0)
2
3
4
6 pnmtopng - convert a PNM image to PNG
7
8
10 pnmtopng [-verbose] [-downscale] [-interlace] [-alpha=file] [-transpar‐
11 ent=[=]color] [-background=color] [-palette=palettefile] [-gamma=value]
12 [-hist] [-text=file] [-ztxt=file] [-rgb='wx wy
13 rx ry gx gy bx by'] [-size='x y unit'] [-modtime='[yy]yy-mm-dd
14 hh:mm:ss'] [-nofilter] [-sub] [-up] [-avg] [-paeth] [-compression=n]
15 [-comp_mem_level=n] [-comp_strategy={huffman_only|filtered}]
16 [-comp_method=deflated] [-comp_window_bits=n] [-comp_buffer_size=n]
17 [-force] [-libversion] [pnmfile]
18
19
20
22 Obsolete options:
23
24 [-filter n]
25
26 Options available only in older versions:
27
28 [-chroma wx wy rx ry gx gy bx by] [-phys x y unit] [-time [yy]yy-mm-dd
29 hh:mm:ss]
30
31 Minimum unique abbreviation of option is acceptable. You may use dou‐
32 ble hyphens instead of single hyphen to denote options. You may use
33 white space in place of the equals sign to separate an option name from
34 its value.
35
36
38 This program is part of Netpbm(1).
39
40 pnmtopng reads a PNM image as input and produces a PNG image as output.
41
42 Color component values in PNG files are either eight or sixteen bits
43 wide, so pnmtopng will automatically scale colors to have a maxval of
44 255 or 65535.
45
46 For a grayscale image, pnmtopng produces a PNG bit depth 1, 2, 4, 8 or
47 16. When the input image has a small maxval, the output PNG image has
48 a correspondingly small bit depth. But in mapping the PNM maxval to
49 the PNG maxval (which is by definition the maximum value that can be
50 represented in the number of bits), a fair amount of distortion happens
51 with these low maxvals. For example, with a PNM maxval of 5 and a PNG
52 maxval of 7, the input sample 2 becomes the output sample 3. The input
53 brightness is 2/5 = .40, while the output brightness is 3/7 = .43.
54 Note that this is not a problem if you view the maxval as a precision,
55 because in .4 and .43 are identical within the precision implied by
56 maxval 5. Indeed, if you convert this PNG back to a maxval 5 PGM, the
57 pixel's value will again be 2, exactly as it was originally. But if
58 you need precisely the same colors in the output PNG as in the input
59 PNM, make sure your input PNM has a maxval which is a power of two
60 minus one. If you can't do that, then convert it with pamdepth to
61 something with a large maxval that is a power of two minus one (255 and
62 65535 are good choices) to minimize the error.
63
64
65
67 pnmtopng changed in Netpbm 10.30 (October 2005) to use the standard
68 Netpbm command line syntax. Before that, you could not use double
69 hyphens to denote an option and could not use an equal sign to separate
70 an option name from its value. And the options had to come before the
71 non-option program arguments.
72
73 Furthermore, the options -chroma, -phys, and -time were replaced by
74 -rgb, size, and -modtime, respectively. The only difference, taking
75 -phys/-size as an example, is that -phys takes multiple program argu‐
76 ments as the option argument, whereas -rgb takes a single program argu‐
77 ment which is composed of multiple words. E.g. The old shell command
78
79 pnmtopng -phys 800 800 0 input.pnm >output.png
80
81 is equivalent to the new shell command
82
83 pnmtopng -size '800 800 0' input.pnm >output.png
84
85 If you're writing a program that needs to work with both new and old
86 pnmtopng, have it first try with the new syntax, and if it fails with
87 'unrecognized option,' fall back to the old syntax.
88
89
90
91 -verbose
92 Display the format of the output file.
93
94 -downscale
95 Enables scaling of maxvalues of more then 65535 to 16 bit.
96 Since
97 this means loss of image data, pnmtopng does not do it by
98 default..TP -interlace
99 Creates an interlaced PNG file (Adam7).
100
101 -alpha=filename
102 This specifies the transparency (alpha channel) of the image.
103 You supply the alpha channel as a standard PGM alpha mask (see
104 the PGM(1)specification.pnmtopngdoesnot necessarily represents
105 the transparency information as an alpha channel in the PNG for‐
106 mat. If it can represent the transparency information through a
107 palette, it will do so in order to make a smaller PNG file.
108 pnmtopng even sorts the palette so it can omit the opaque colors
109 from the transparency part of the palette and save space for the
110 palette.
111
112
113 -transparent=color
114 pnmtopng marks the specified color as transparent in the PNG
115 image.
116
117 Specify the color (color) as described for the argument of the
118 ppm_parsecolor() library routine ⟨libppm.html#colorname⟩ . E.g.
119 red or rgb:ff/00/0d. If the color you specify is not present in
120 the image, pnmtopng selects instead the color in the image that
121 is closest to the one you specify. Closeness is measured as a
122 cartesian distance between colors in RGB space. If multiple
123 colors are equidistant, pnmtopng chooses one of them arbitrar‐
124 ily.
125
126 However, if you prefix your color specification with '=', e.g.
127
128 -transparent =red
129
130 only the exact color you specify will be transparent. If that
131 color does not appear in the image, there will be no trans‐
132 parency. pnmtopng issues an information message when this is
133 the case.
134
135
136 -background=color
137 Causes pnmtopng to create a background color chunk in the PNG
138 output which can be used for subsequent alpha channel or trans‐
139 parent color conversions. Specify color the same as for -trans‐
140 parent.
141
142
143 -palette=palettefile
144 This option specifies a palette to use in the PNG. It forces
145 pnmtopng to create the paletted (colormapped) variety of PNG --
146 if that isn't possible, pnmtopng fails. If the palette you
147 specify doesn't contain exactly the colors in the image, pnm‐
148 topng fails. Since pnmtopng will automatically generate a
149 paletted PNG, with a correct palette, when appropriate, the only
150 reason you would specify the -palette option is if you care in
151 what order the colors appear in the palette. The PNG palette
152 has colors in the same order as the palette you specify.
153
154 You specify the palette by naming a PPM file that has one pixel
155 for each color in the palette.
156
157 Alternatively, consider the case that have a palette and you
158 want to make sure your PNG contains only colors from the pal‐
159 ette, approximating if necessary. You don't care what indexes
160 the PNG uses internally for the colors (i.e. the order of the
161 PNG palette). In this case, you don't need -palette. Pass the
162 Netpbm input image and your palette PPM through pnmremap.
163 Though you might think it would, using -palette in this case
164 wouldn't even save pnmtopng any work.
165
166
167 -gamma=value
168 Causes pnmtopng to create a gAMA chunk. This information helps
169 describe how the color values in the PNG must be interpreted.
170 Without the gAMA chunk, whatever interprets the PNG must get
171 this information separately (or just assume something standard).
172 If your input is a true PPM or PGM image, you should specify
173 -gamma=.45. But sometimes people generate images which are
174 ostensibly PPM except the image uses a different gamma transfer
175 function than the one specified for PPM. A common case of this
176 is when the image is created by simple hardware that doesn't
177 have digital computational ability. Also, some simple programs
178 that generate images from scratch do it with a gamma transfer in
179 which the gamma value is 1.0.
180
181
182 -hist Use this parameter to create a chunk that specifies the fre‐
183 quency (or histogram) of the colors in the image.
184
185
186 -rgb=chroma_list
187 This option specifies how red, green, and blue component values
188 of a pixel specify a particular color, by telling the chromatic‐
189 ities of those 3 primary illuminants and of white (i.e. full
190 strength of all three).
191
192 The chroma_list value is a blank-separated list of 8 floating
193 point decimal numbers. The CIE-1931 X and Y chromaticities (in
194 that order) of each of white, red, green, and blue, in that
195 order.
196
197 This information goes into the PNG's cHRM chunk.
198
199 In a shell command, make sure you use quotation marks so that
200 the blanks in chroma_list don't make the shell see multiple com‐
201 mand arguments.
202
203 This option was new in Netpbm 10.30 (October 2005). Before
204 that, the option -chroma does the same thing, but with slightly
205 different syntax.
206
207
208 -size='x y unit'
209 This option determines the aspect ratio of the individual pixels
210 of your image as well as the physical resolution of it.
211
212 unit is either 0 or 1. When it is 1, the option specifies the
213 physical resolution of the image in pixels per meter. For exam‐
214 ple, -size='10000 15000 1' means that when someone displays the
215 image, he should make it so that 10,000 pixels horizontally
216 occupy 1 meter and 15,000 pixels vertically occupy one meter.
217 And even if he doesn't take this advice on the overall size of
218 the displayed image, he should at least make it so that each
219 pixel displays as 1.5 times as high as wide.
220
221 When unit is 0, that means there is no advice on the absolute
222 physical resolution; just on the ratio of horizontal to vertical
223 physical resolution.
224
225 This information goes into the PNG's pHYS chunk.
226
227 When you don't specify -size, pnmtopng creates the image with no
228 pHYS chunk, which means square pixels of no absolute resolution.
229
230 This option was new in Netpbm 10.30 (October 2005). Before
231 that, the option -phys does the same thing, but with slightly
232 different syntax.
233
234
235 -text=filename
236 This option lets you include comments in the text chunk of the
237 PNG output. file is the name of a file that contains your text
238 comments.
239
240 Here is an example of a comment file:
241 Title PNG file
242
243 Author Bryan Henderson
244
245 Description how to include a text chunk
246 PNG file
247 "Creation date" 3-feb-1987
248
249 Software pnmtopng
250
251 The format of the file is as follows: The file is divided into
252 lines, delimited by newline characters. The last line need not
253 end with a newline character. A group of consecutive lines rep‐
254 resents a comment.
255
256 A "delimiter character" is a blank or tab or null character.
257 The first line representing a comment must not start with a
258 delimiter character. Every other line in the group is a "con‐
259 tinuation line" and must start with a delimiter character.
260
261 The first line representing a comment consists of a keyword and
262 the first line of comment text. The keyword begins in Column 1
263 of the file line and continues up to, but not including, the
264 first delimiter character, or the end of the line, whichever is
265 first. Exception: you can enclose the keyword in double quotes
266 and spaces and tabs within the double quotes are part of the
267 keyword. The quotes are not part of the keyword. A NUL charac‐
268 ter is not allowed in a keyword.
269
270 The first line of the comment text is all the text in the file
271 line beginning after the keyword and any delimiter characters
272 after it. immediately after the delimiter character that marks
273 the end of the keyword.
274
275 A continuation line defines a subsequent line of the comment.
276 The comment line is all the text on the continuation line start‐
277 ing with the first non-delimiter character.
278
279 There is one newline character between every two comment lines.
280 There is no newline character after the last line of comment
281 text.
282
283 There is no limit on the length of a file line or keyword or
284 comment text line or comment text. There is no limit on the
285 number of comments or size of or number of lines in the file.
286
287
288 -ztxt=filename
289 The same as -text, except pnmtopng considers the text com‐
290 pressed.
291
292
293 -modtime='[yy]yy-mm-dd hh:mm:ss'
294 This option allows you to specify the modification time value to
295 be placed in the PNG output. You can specify the year parameter
296 either as a two digit or four digit value.
297
298 This option was new in Netpbm 10.30 (October 2005). Before
299 that, the option -time does the same thing, but with slightly
300 different syntax.
301
302
303 -filter=n
304 This option is obsolete. Before Netpbm 10.22 (April 2004), this
305 was the only way to specify a row filter. It specifies a single
306 type of row filter, by number, that pnmtopng must use on each
307 row.
308
309 Use -nofilter, -sub, -up, -avg, and -paeth in current Netpbm.
310
311
312 -nofilter
313
314 -sub
315
316 -up
317
318 -avg
319
320 -paeth Each of these options permits pnmtopng to use one type of row
321 filter. pnmtopng chooses whichever of the permitted filters it
322 finds to be optimal. If you specify none of these options, it
323 is the same as specifying all of them -- pnmtopng uses any row
324 filter type it finds optimal.
325
326 These options were new with Netpbm 10.22 (April 2004). Before
327 that, you could use the -filter option to specify one permitted
328 row filter type. The default, when you specify no filter
329 options, was the same.
330
331
332 -compression=n
333 This option sets set the compression level of the zlib compres‐
334 sion. Select a level from 0 for no compression (maximum speed)
335 to 9 for maximum compression (minimum speed).
336
337
338 -comp_mem_level=n
339 This option sets the memory usage level of the zlib compression.
340 Select a level from 1 for minimum memory usage (and minimum
341 speed) to 9 for maximum memory usage (and speed).
342
343 This option was new in Netpbm 10.30 (October 2005).
344
345
346 -comp_strategy={huffman_only|filtered}
347 This options sets the compression strategy of the zlib compres‐
348 sion. See Zlib documentation for information on what these
349 strategies are.
350
351 This option was new in Netpbm 10.30 (October 2005).
352
353
354 -comp_method=deflated
355 This option does nothing. It is here for mathematical complete‐
356 ness and for possible forward compatibility. It theoretically
357 selects the compression method of the zlib compression, but the
358 Z library knows only one method today, so there's nothing to
359 choose.
360
361 This option was new in Netpbm 10.30 (October 2005).
362
363
364 -comp_window_bits=N
365 This option tells how big a window the zlib compression algo‐
366 rithm uses. The value is the base 2 logarithm of the window
367 size in bytes, so 8 means 256 bytes. The value must be from 8
368 to 15 (i.e. 256 bytes to 32K).
369
370 See Zlib documentation for details on what this window size is.
371
372 This option was new in Netpbm 10.30 (October 2005).
373
374
375 -comp_buffer_size=N
376 This option determines in what size pieces pnmtopng does the
377 zlib compression. One compressed piece goes in each IDAT chunk
378 in the PNG. So the bigger this value, the fewer IDAT chunks
379 your PNG will have. Theoretically, this makes the PNG smaller
380 because 1) you have less per-IDAT-chunk overhead, and 2) the
381 compression algorithm has more data to work with. But in real‐
382 ity, the difference will probably not be noticeable above about
383 8K, which is the default.
384
385 The value n is the size of the compressed piece (i.e. the com‐
386 pression buffer) in bytes.
387
388 This option was new in Netpbm 10.30 (October 2005).
389
390
391
392 -force When you specify this, pnmtopng limits its optimizations. The
393 resulting PNG output is as similar to the Netpbm input as possi‐
394 ble. For example, the PNG output will not be paletted and the
395 alpha channel will be represented as a full alpha channel even
396 if the information could be represented more succinctly with a
397 transparency chunk.
398
399
400
401 -libversion
402 This option causes pnmtopng to display version information about
403 itself and the libraries it uses, in addition to all its normal
404 function. Do not confuse this with the Netpbm common option
405 -version, which causes the program to display version informa‐
406 tion about the Netpbm library and do nothing else.
407
408 You can't really use this option in a program that invokes pnm‐
409 topng and needs to know which version it is. Its function has
410 changed too much over the history of pnmtopng. The option is
411 only good for human eyes.
412
413
414
415
417 pngtopam(1), pamrgbatopng(1), pnmremap(1), pnmgamma(1), pnm(1)
418
419 For information on the PNG format, see http://schaik.com/png
420 ⟨http://schaik.com/png⟩ .
421
422
424 Copyright (C) 1995-1997 by Alexander Lehmann and Willem van Schaik.
425
426
427
428netpbm documentation July 2008 Pnmtopng User Manual(0)