1Pnmtopng User Manual(0)                                Pnmtopng User Manual(0)
2
3
4

NAME

6       pnmtopng - convert a PNM image to PNG
7
8

SYNOPSIS

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'] [-srgbintent=intent] [-mod‐
14       time='[yy]yy-mm-dd
15         hh:mm:ss'] [-nofilter] [-sub] [-up] [-avg] [-paeth]  [-compression=n]
16       [-comp_mem_level=n]            [-comp_strategy={huffman_only|filtered}]
17       [-comp_method=deflated]   [-comp_window_bits=n]   [-comp_buffer_size=n]
18       [-force] [-libversion] [pnmfile]
19
20
21

OPTION USAGE

23       Obsolete options:
24
25       [-filter n]
26
27       Options available only in older versions:
28
29       [-chroma wx wy rx ry gx gy bx by] [-phys x y unit] [-time [yy]yy-mm-dd
30         hh:mm:ss]
31
32       Minimum  unique abbreviation of option is acceptable.  You may use dou‐
33       ble hyphens instead of single hyphen to denote options.   You  may  use
34       white space in place of the equals sign to separate an option name from
35       its value.
36
37

DESCRIPTION

39       This program is part of Netpbm(1).
40
41       pnmtopng reads a PNM image as input and produces a PNG image as output.
42
43       Color component values in PNG files are either eight  or  sixteen  bits
44       wide,  so  pnmtopng will automatically scale colors to have a maxval of
45       255 or 65535.
46
47       For a grayscale image, pnmtopng produces a PNG bit depth 1, 2, 4, 8  or
48       16.   When the input image has a small maxval, the output PNG image has
49       a correspondingly small bit depth.  But in mapping the  PNM  maxval  to
50       the  PNG  maxval  (which is by definition the maximum value that can be
51       represented in the number of bits), a fair amount of distortion happens
52       with  these low maxvals.  For example, with a PNM maxval of 5 and a PNG
53       maxval of 7, the input sample 2 becomes the output sample 3.  The input
54       brightness  is  2/5  =  .40,  while the output brightness is 3/7 = .43.
55       Note that this is not a problem if you view the maxval as a  precision,
56       because  in  .4  and  .43 are identical within the precision implied by
57       maxval 5.  Indeed, if you convert this PNG back to a maxval 5 PGM,  the
58       pixel's  value  will  again be 2, exactly as it was originally.  But if
59       you need precisely the same colors in the output PNG as  in  the  input
60       PNM,  make sure your input PNM has a maxval which is a power of two mi‐
61       nus one.  If you can't do that, then convert it with pamdepth to  some‐
62       thing  with  a  large  maxval that is a power of two minus one (255 and
63       65535 are good choices) to minimize the error.
64
65
66

OPTIONS

68   Note: Option Syntax of Older Versions
69       pnmtopng changed in Netpbm 10.30 (October 2005)  to  use  the  standard
70       Netpbm  command line syntax.  Before that, you could not use double hy‐
71       phens to denote an option and could not use an equal sign  to  separate
72       an  option name from its value.  And the options had to come before the
73       non-option program arguments.
74
75       Furthermore, the options -chroma, -phys, and  -time  were  replaced  by
76       -rgb,  -size,  and -modtime, respectively.  The only difference, taking
77       -phys/-size as an example, is that -phys takes multiple  program  argu‐
78       ments  as the option argument, whereas -size takes a single program ar‐
79       gument which is composed of multiple words.  E.g.  The old  shell  com‐
80       mand
81
82          pnmtopng -phys 800 800 0 input.pnm > output.png
83
84
85       is equivalent to the new shell command
86
87          pnmtopng -size "800 800 0" input.pnm > output.png
88
89
90       If  you're writing a program that needs to work with both new and old ,
91       have it first try with the new syntax, and if it fails  with  "unrecog‐
92       nized option," fall back to the old syntax.
93
94
95   Current Options
96       In  addition  to  the options common to all programs based on libnetpbm
97       (most notably -quiet, see
98        Common Options ⟨index.html#commonoptions⟩ ), pnmtopng  recognizes  the
99       following command line options:
100
101
102
103       -verbose
104              This  causes pnmtopng to display information about the format of
105              the output file.
106
107
108
109
110       -downscale
111              This enables pnmtopng to scale maxvalues of more then  65535  to
112              16  bits. Since this means loss of image data, pnmtopng does not
113              do it by default.
114
115
116
117
118       -interlace
119              This causes the PNG file to be interlaced, in Adam7 format.  The
120              interlaced  format is one in which the raster data starts with a
121              low-resolution representation of the entire image, then  contin‐
122              ues  with additional information for the entire image, then even
123              more information, etc.  In Adam7 in particular, there are  seven
124              such passes of the whole image.  This is useful when you are re‐
125              ceiving the image over a slow communication line as  someone  is
126              waiting  to  see  it.   The simplest thing to do in that case is
127              wait for the entire image to arrive  and  then  display  it  in‐
128              stantly,  but  then  the user is wasting time staring at a blank
129              space until the whole image arrives.  With the standard  non-in‐
130              terlaced  format,  the  data  arrives row-by-row starting at the
131              top, so the displayer could display each row of the image as  it
132              arrives and gradually paint down to the bottom.  But with an in‐
133              terlaced image, the displayer can start by showing a low-resolu‐
134              tion version of the image, then gradually improve the display as
135              more data arrives.
136
137
138
139
140       -alpha=filename
141              This specifies the transparency (alpha) channel  of  the  image.
142              You  supply the transparency channel as a standard PGM transpar‐
143              ency mask (see the PGM(1) specification.  pnmtopng does not nec‐
144              essarily  represents the transparency information as a transpar‐
145              ency channel in the PNG format.  If it can represent the  trans‐
146              parency information through a palette, it will do so in order to
147              make a smaller PNG file.  pnmtopng even sorts the palette so  it
148              can  omit  the  opaque  colors from the transparency part of the
149              palette and save space for the palette.
150
151
152
153
154       -transparent=color
155              pnmtopng marks the specified color as transparent in the PNG im‐
156              age.
157
158              Specify  the  color (color) as described for the argument of the
159              pnm_parsecolor()                 library                 routine
160              ⟨libnetpbm_image.html#colorname⟩  .   E.g.  red or rgb:ff/00/0d.
161              If the color you specify is not present in the  image,  pnmtopng
162              selects  instead  the  color in the image that is closest to the
163              one you specify.  Closeness is measured as a Cartesian  distance
164              between  colors  in  RGB space.  If multiple colors are equidis‐
165              tant, pnmtopng chooses one of them arbitrarily.
166
167              However, if you prefix your color specification with "=", e.g.
168
169                                  -transparent =red
170
171
172               only the exact color you specify will be transparent.  If  that
173              color  does  not appear in the image, there will be no transpar‐
174              ency.  pnmtopng issues an information message when this  is  the
175              case.
176
177
178       -background=color
179              Causes  pnmtopng  to  create a background color chunk in the PNG
180              output which can be used for subsequent transparency channel  or
181              transparent  color  conversions.   Specify color the same as for
182              -transparent.
183
184
185
186
187       -palette=palettefile
188              This option specifies a palette to use in the  PNG.   It  forces
189              pnmtopng  to create the paletted (colormapped) variety of PNG --
190              if that isn't possible, pnmtopng  fails.   If  the  palette  you
191              specify  doesn't  contain  exactly the colors in the image, pnm‐
192              topng fails.   Since  pnmtopng  will  automatically  generate  a
193              paletted PNG, with a correct palette, when appropriate, the only
194              reason you would specify the -palette option is if you  care  in
195              what  order  the  colors appear in the palette.  The PNG palette
196              has colors in the same order as the palette you specify.
197
198              You specify the palette by naming a PPM file that has one  pixel
199              for each color in the palette.
200
201              Alternatively,  consider  the  case  that have a palette and you
202              want to make sure your PNG contains only colors  from  the  pal‐
203              ette,  approximating  if necessary.  You don't care what indexes
204              the PNG uses internally for the colors (i.e. the  order  of  the
205              PNG  palette).  In this case, you don't need -palette.  Pass the
206              Netpbm input  image  and  your  palette  PPM  through  pnmremap.
207              Though  you  might  think  it would, using -palette in this case
208              wouldn't even save pnmtopng any work.
209
210
211       -gamma=value
212              Causes pnmtopng to create a gAMA chunk.  This information  helps
213              describe  how  the  color values in the PNG must be interpreted.
214              Without the gAMA chunk, whatever interprets  the  PNG  must  get
215              this information separately (or just assume something standard).
216              If your input is a true PPM or PGM  image,  you  should  specify
217              -gamma=.52.   But sometimes people generate images which are os‐
218              tensibly PPM except the image uses a  different  gamma  transfer
219              function  than the one specified for PPM.  A common case of this
220              is when the image is created by  simple  hardware  that  doesn't
221              have  digital computational ability.  Also, some simple programs
222              that generate images from scratch do it with a gamma transfer in
223              which the gamma value is 1.0.
224
225
226
227
228       -hist  Use  this  parameter  to  create a chunk that specifies the fre‐
229              quency (or histogram) of the colors in the image.
230
231
232
233
234       -text=filename
235              This option lets you include arbitrary text strings in  the  PNG
236              output, as tEXt chunks.
237
238              filename is the name of a file that contains your text strings.
239
240              The  output contains a distinct tEXt chunk for each entry in the
241              file.
242
243              Here is an example of a text string file:
244
245                   Title           PNG file
246                   Author          John Doe
247                   Description     how to include a text chunk
248                                      PNG file
249                   "Creation Date" 2015-may-11
250                   Software        pamtopng
251
252
253              The file is divided into entries, each entry comprising consecu‐
254              tive  lines  of  text.  The first line of an entry starts in the
255              first column (i.e. the first column is not white space) and  ev‐
256              ery  other  line has white space in the first column.  The first
257              entry starts in the first line, so it is not valid for the first
258              line of the file to have white space in its first column.
259
260              The  first  word in an entry is the key of the text string (e.g.
261              'Title').  It begins in column one of the line and continues  up
262              to,  but not including, the first delimiter character or the end
263              of the line, whichever is first.  You can  enclose  the  key  in
264              double  quotes  in  which  case the key can consists of multiple
265              words.  The quotes are not part of the key.  The text string per
266              se  begins  after the key and any delimiter characters after it,
267              plus the text in subsequent continuation lines.
268
269              There is no limit on the length of a file line or entry  or  key
270              or text string.  There is no limit on the number of entries.
271
272
273       -ztxt=filename
274              The  same  as -text, except the text string is compressed in the
275              PNG output.  pnmtopng uses zTXt chunks instead of a tEXt chunks,
276              unless the key for the text string starts with 'A' or 'T'.  This
277              odd exception exists for backward compatibility; we  don't  know
278              why  the  program  was originally designed this way, except that
279              the distinction was meant to roughly identify the keys  'Author'
280              and 'Title'.
281
282
283
284
285       -rgb=chroma_list
286              This  option specifies how red, green, and blue component values
287              of a pixel specify a particular color, by telling the chromatic‐
288              ities  of  those  3  primary illuminants and of white (i.e. full
289              strength of all three).
290
291              The chroma_list value is a blank-separated list  of  8  floating
292              point  decimal numbers.  The CIE-1931 X and Y chromaticities (in
293              that order) of each of white, red, green, and blue, in that  or‐
294              der.
295
296              This information goes into the PNG's cHRM chunk.
297
298              In  a  shell  command, make sure you use quotation marks so that
299              the blanks in chroma_list don't make the shell see multiple com‐
300              mand arguments.
301
302              This  option  was  new  in  Netpbm 10.30 (October 2005).  Before
303              that, the option -chroma does the same thing, but with  slightly
304              different syntax.
305
306
307       -size="x y unit"
308              This option determines the aspect ratio of the individual pixels
309              of your image as well as the physical resolution of it.
310
311              unit is either 0 or 1.  When it is 1, the option  specifies  the
312              physical resolution of the image in pixels per meter.  For exam‐
313              ple, -size="10000 15000 1" means that when someone displays  the
314              image,  he should make it so that 10,000 pixels horizontally oc‐
315              cupy 1 meter and 15,000 pixels vertically occupy one meter.  And
316              even  if  he doesn't take this advice on the overall size of the
317              displayed image, he should at least make it so that  each  pixel
318              displays as 1.5 times as high as wide.
319
320              When  unit  is  0, that means there is no advice on the absolute
321              physical resolution; just on the ratio of horizontal to vertical
322              physical resolution.
323
324              This information goes into the PNG's pHYS chunk.
325
326              When you don't specify -size, pnmtopng creates the image with no
327              pHYS chunk, which means square pixels of no absolute resolution.
328
329              This option was new in  Netpbm  10.30  (October  2005).   Before
330              that,  the  option  -phys does the same thing, but with slightly
331              different syntax.
332
333
334       -srgbintent=intent
335              This asserts that the input is a pseudo-Netpbm image  that  uses
336              an  sRGB  color space (unlike true Netpbm) and indicates how you
337              intend for the colors to be rendered.  It causes pnmtopng to in‐
338              clude an sRGB chunk in the PNG image that specifies that intent,
339              so see the PNG documentation for more information on  what  this
340              really means.
341
342              intent is one of:
343
344
345
346perceptual
347
348relativecolorimetric
349
350saturation
351
352absolutecolorimetric
353
354
355              This  option  was new in Netpbm 10.71 (June 2015).  Before that,
356              pnmtopng never generates an sRGB chunk.
357
358
359       -modtime="[yy]yy-mm-dd hh:mm:ss"
360              This option allows you to specify the modification time value to
361              be placed in the PNG output.  You can specify the year parameter
362              either as a two digit or four digit value.
363
364              This option was new in  Netpbm  10.30  (October  2005).   Before
365              that,  the  option  -time does the same thing, but with slightly
366              different syntax.
367
368
369       -filter=n
370              This option is obsolete.  Before Netpbm 10.22 (April 2004), this
371              was the only way to specify a row filter.  It specifies a single
372              type of row filter, by number, that pnmtopng must  use  on  each
373              row.
374
375              Use -nofilter, -sub, -up, -avg, and -paeth in current Netpbm.
376
377
378       -nofilter
379
380       -sub
381
382       -up
383
384       -avg
385
386       -paeth Each  of  these  options permits pnmtopng to use one type of row
387              filter.  pnmtopng chooses whichever of the permitted filters  it
388              finds  to  be optimal.  If you specify none of these options, it
389              is the same as specifying all of them -- pnmtopng uses  any  row
390              filter type it finds optimal.
391
392              These  options  were new with Netpbm 10.22 (April 2004).  Before
393              that, you could use the -filter option to specify one  permitted
394              row  filter  type.   The default, when you specify no filter op‐
395              tions, was the same.
396
397
398       -compression=n
399              This option sets set the compression level of the zlib  compres‐
400              sion.   Select a level from 0 for no compression (maximum speed)
401              to 9 for maximum compression (minimum speed).
402
403              The default is the default of the zlib library.
404
405
406       -comp_mem_level=n
407              This option sets the memory usage level of the zlib compression.
408              Select  a  level  from  1  for minimum memory usage (and minimum
409              speed) to 9 for maximum memory usage (and speed).
410
411              The default is the default of the zlib library.
412
413              This option was new in Netpbm 10.30 (October 2005).
414
415
416       -comp_strategy={huffman_only|filtered}
417              This options sets the compression strategy of the zlib  compres‐
418              sion.   See  Zlib  documentation  for  information on what these
419              strategies are.
420
421              The default is the default of the zlib library.
422
423              This option was new in Netpbm 10.30 (October 2005).
424
425
426       -comp_method=deflated
427              This option does nothing.  It is here for mathematical complete‐
428              ness  and  for possible forward compatibility.  It theoretically
429              selects the compression method of the zlib compression, but  the
430              Z  library  knows  only  one method today, so there's nothing to
431              choose.
432
433              The default is the default of the zlib library.
434
435              This option was new in Netpbm 10.30 (October 2005).
436
437
438       -comp_window_bits=N
439              This option tells how big a window the  zlib  compression  algo‐
440              rithm  uses.   The  value  is the base 2 logarithm of the window
441              size in bytes, so 8 means 256 bytes.  The value must be  from  8
442              to 15 (i.e. 256 bytes to 32K).
443
444              See Zlib documentation for details on what this window size is.
445
446              The default is the default of the zlib library.
447
448              This option was new in Netpbm 10.30 (October 2005).
449
450
451       -comp_buffer_size=N
452              This  option  determines  in  what size pieces pnmtopng does the
453              zlib compression.  One compressed piece goes in each IDAT  chunk
454              in  the  PNG.   So  the bigger this value, the fewer IDAT chunks
455              your PNG will have.  Theoretically, this makes the  PNG  smaller
456              because  1)  you  have  less per-IDAT-chunk overhead, and 2) the
457              compression algorithm has more data to work with.  But in  real‐
458              ity,  the difference will probably not be noticeable above about
459              8K, which is the default.
460
461              The value n is the size of the compressed piece (i.e.  the  com‐
462              pression buffer) in bytes.
463
464              This option was new in Netpbm 10.30 (October 2005).
465
466
467
468       -force When  you  specify this, pnmtopng limits its optimizations.  The
469              resulting PNG output is as similar to the Netpbm input as possi‐
470              ble.   For  example, the PNG output will not be paletted and the
471              transparency channel will be represented as a full  transparency
472              channel  even  if the information could be represented more suc‐
473              cinctly with a transparency chunk.
474
475
476
477
478       -libversion
479              This option causes pnmtopng to display version information about
480              itself  and the libraries it uses, in addition to all its normal
481              function.  Do not confuse this with  the  Netpbm  common  option
482              -version,  which  causes the program to display version informa‐
483              tion about the Netpbm library and do nothing else.
484
485              You can't really use this option in a program that invokes  pnm‐
486              topng  and  needs to know which version it is.  Its function has
487              changed too much over the history of pnmtopng.   The  option  is
488              good only for human eyes.
489
490
491
492

SEE ALSO

494       pngtopam(1), pamtopng(1), pnmremap(1), pnmgamma(1), pnm(1)
495
496       For   information   on   the   PNG  format,  see  http://schaik.com/png
497http://schaik.com/png⟩ .
498
499

AUTHOR

501       Copyright (C) 1995-1997 by Alexander Lehmann and Willem van Schaik.
502

DOCUMENT SOURCE

504       This manual page was generated by the Netpbm tool 'makeman'  from  HTML
505       source.  The master documentation is at
506
507              http://netpbm.sourceforge.net/doc/pnmtopng.html
508
509netpbm documentation             13 March 2019         Pnmtopng User Manual(0)
Impressum