\ .\" This man page was generated by the Netpbm tool 'makeman' from HTML source. .\" Do not hand-hack it! If you have bug fixes or improvements, please find .\" the corresponding HTML page on the Netpbm website, generate a patch .\" against that, and send it to the Netpbm maintainer. .TH "Pnmtopng User Manual" 1 "13 March 2019" "netpbm documentation" .SH NAME pnmtopng - convert a PNM image to PNG .UN synopsis .SH SYNOPSIS \fBpnmtopng\fP [\fB-verbose\fP] [\fB-downscale\fP] [\fB-interlace\fP] [\fB-alpha=\fP\fIfile\fP] [\fB-transparent=\fP[\fB=\fP]\fIcolor\fP] [\fB-background=\fP\fIcolor\fP] [\fB-palette=\fP\fIpalettefile\fP] [\fB-gamma=\fP\fIvalue\fP] [\fB-hist\fP] [\fB-text=\fP\fIfile\fP] [\fB-ztxt=\fP\fIfile\fP] [\fB-rgb='\fP\fIwx\fP \fIwy\fP \fIrx\fP \fIry\fP \fIgx\fP \fIgy\fP \fIbx\fP \fIby\fP\fB'\fP] [\fB-size='\fP\fIx\fP \fIy\fP \fIunit\fP\fB'\fP] [\fB-srgbintent=\fP\fIintent\fP] [\fB-modtime='\fP[\fIyy\fP]\fIyy\fP\fB-\fP\fImm\fP\fB-\fP\fIdd\fP \fIhh\fP\fB:\fP\fImm\fP\fB:\fP\fIss\fP\fB'\fP] [\fB-nofilter\fP] [\fB-sub\fP] [\fB-up\fP] [\fB-avg\fP] [\fB-paeth\fP] [\fB-compression=\fP\fIn\fP] [\fB-comp_mem_level=\fP\fIn\fP] [\fB-comp_strategy=\fP{\fBhuffman_only\fP|\fBfiltered\fP}] [\fB-comp_method=\fP\fBdeflated\fP] [\fB-comp_window_bits=\fP\fIn\fP] [\fB-comp_buffer_size=\fP\fIn\fP] [\fB-force\fP] [\fB-libversion\fP] [\fIpnmfile\fP] .SH OPTION USAGE .PP Obsolete options: .PP [\fB-filter \fP\fIn\fP] .PP Options available only in older versions: .PP [\fB-chroma\fP \fIwx wy rx ry gx gy bx by\fP] [\fB-phys\fP \fIx\fP \fIy\fP \fIunit\fP] [\fB-time \fP[\fIyy\fP]\fIyy\fP\fB-\fP\fImm\fP\fB-\fP\fIdd\fP \fIhh\fP\fB:\fP\fImm\fP\fB:\fP\fIss\fP] .PP Minimum unique abbreviation of option is acceptable. You may use double hyphens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value. .UN description .SH DESCRIPTION .PP This program is part of .BR "Netpbm" (1)\c \&. .PP \fBpnmtopng\fP reads a PNM image as input and produces a PNG image as output. .PP Color component values in PNG files are either eight or sixteen bits wide, so \fBpnmtopng\fP will automatically scale colors to have a maxval of 255 or 65535. .PP For a grayscale image, \fBpnmtopng\fP produces a PNG bit depth 1, 2, 4, 8 or 16. When the input image has a small maxval, the output PNG image has a correspondingly small bit depth. But in mapping the PNM maxval to the PNG maxval (which is by definition the maximum value that can be represented in the number of bits), a fair amount of distortion happens with these low maxvals. For example, with a PNM maxval of 5 and a PNG maxval of 7, the input sample 2 becomes the output sample 3. The input brightness is 2/5 = .40, while the output brightness is 3/7 = .43. Note that this is not a problem if you view the maxval as a precision, because in .4 and .43 are identical within the precision implied by maxval 5. Indeed, if you convert this PNG back to a maxval 5 PGM, the pixel's value will again be 2, exactly as it was originally. But if you need precisely the same colors in the output PNG as in the input PNM, make sure your input PNM has a maxval which is a power of two minus one. If you can't do that, then convert it with \fBpamdepth\fP to something with a large maxval that is a power of two minus one (255 and 65535 are good choices) to minimize the error. .UN options .SH OPTIONS .UN notesyntax .SS Note: Option Syntax of Older Versions .PP \fBpnmtopng\fP changed in Netpbm 10.30 (October 2005) to use the standard Netpbm command line syntax. Before that, you could not use double hyphens to denote an option and could not use an equal sign to separate an option name from its value. And the options had to come before the non-option program arguments. .PP Furthermore, the options \fB-chroma\fP, \fB-phys\fP, and \fB-time\fP were replaced by \fB-rgb\fP, \fB-size\fP, and \fB-modtime\fP, respectively. The only difference, taking \fB-phys\fP/\fB-size\fP as an example, is that \fB-phys\fP takes multiple program arguments as the option argument, whereas \fB-size\fP takes a single program argument which is composed of multiple words. E.g. the old shell command .nf \f(CW pnmtopng -phys 800 800 0 input.pnm > output.png \fP .fi .PP is equivalent to the new shell command .nf \f(CW pnmtopng -size "800 800 0" input.pnm > output.png \fP .fi .PP If you're writing a program that needs to work with both new and old , have it first try with the new syntax, and if it fails with "unrecognized option," fall back to the old syntax. .UN curroptions .SS Current Options .PP In addition to the options common to all programs based on libnetpbm (most notably \fB-quiet\fP, see .UR index.html#commonoptions Common Options .UE \&), \fBpnmtopng\fP recognizes the following command line options: .TP \fB-verbose\fP This causes \fBpnmtopng\fP to display information about the format of the output file. .sp \ .TP \fB-downscale\fP This enables \fBpnmtopng\fP to scale maxvalues of more then 65535 to 16 bits. Since this means loss of image data, \fBpnmtopng\fP does not do it by default. .sp \ .TP \fB-interlace\fP This causes the PNG file to be interlaced, in Adam7 format. The interlaced format is one in which the raster data starts with a low-resolution representation of the entire image, then continues with additional information for the entire image, then even more information, etc. In Adam7 in particular, there are seven such passes of the whole image. This is useful when you are receiving the image over a slow communication line as someone is waiting to see it. The simplest thing to do in that case is wait for the entire image to arrive and then display it instantly, but then the user is wasting time staring at a blank space until the whole image arrives. With the standard non-interlaced format, the data arrives row-by-row starting at the top, so the displayer could display each row of the image as it arrives and gradually paint down to the bottom. But with an interlaced image, the displayer can start by showing a low-resolution version of the image, then gradually improve the display as more data arrives. .sp \ .TP \fB-alpha=\fP\fIfilename\fP This specifies the transparency (alpha) channel of the image. You supply the transparency channel as a standard PGM transparency mask (see the .BR "PGM" (1)\c \& specification. \fBpnmtopng\fP does not necessarily represents the transparency information as a transparency channel in the PNG format. If it can represent the transparency information through a palette, it will do so in order to make a smaller PNG file. \fBpnmtopng\fP even sorts the palette so it can omit the opaque colors from the transparency part of the palette and save space for the palette. .sp \ .TP \fB-transparent=\fP\fIcolor\fP \fBpnmtopng\fP marks the specified color as transparent in the PNG image. .sp Specify the color (\fIcolor\fP) as described for the .UR libnetpbm_image.html#colorname argument of the \fBpnm_parsecolor()\fP library routine .UE \&. E.g. \fBred\fP or \fBrgb:ff/00/0d\fP. If the color you specify is not present in the image, \fBpnmtopng\fP selects instead the color in the image that is closest to the one you specify. Closeness is measured as a Cartesian distance between colors in RGB space. If multiple colors are equidistant, \fBpnmtopng\fP chooses one of them arbitrarily. .sp However, if you prefix your color specification with "=", e.g. .nf \f(CW -transparent =red \fP .fi .sp only the exact color you specify will be transparent. If that color does not appear in the image, there will be no transparency. \fBpnmtopng\fP issues an information message when this is the case. .TP \fB-background=\fP\fIcolor\fP Causes \fBpnmtopng\fP to create a background color chunk in the PNG output which can be used for subsequent transparency channel or transparent color conversions. Specify \fIcolor\fP the same as for \fB-transparent\fP. .sp \ .TP \fB-palette=\fP\fIpalettefile\fP This option specifies a palette to use in the PNG. It forces \fBpnmtopng\fP to create the paletted (colormapped) variety of PNG -- if that isn't possible, \fBpnmtopng\fP fails. If the palette you specify doesn't contain exactly the colors in the image, \fBpnmtopng\fP fails. Since \fBpnmtopng\fP will automatically generate a paletted PNG, with a correct palette, when appropriate, the only reason you would specify the \fB-palette\fP option is if you care in what order the colors appear in the palette. The PNG palette has colors in the same order as the palette you specify. .sp You specify the palette by naming a PPM file that has one pixel for each color in the palette. .sp Alternatively, consider the case that have a palette and you want to make sure your PNG contains only colors from the palette, approximating if necessary. You don't care what indexes the PNG uses internally for the colors (i.e. the order of the PNG palette). In this case, you don't need \fB-palette\fP. Pass the Netpbm input image and your palette PPM through \fBpnmremap\fP. Though you might think it would, using \fB-palette\fP in this case wouldn't even save \fBpnmtopng\fP any work. .TP \fB-gamma=\fP\fIvalue\fP Causes \fBpnmtopng\fP to create a gAMA chunk. This information helps describe how the color values in the PNG must be interpreted. Without the gAMA chunk, whatever interprets the PNG must get this information separately (or just assume something standard). If your input is a true PPM or PGM image, you should specify \fB-gamma=.52\fP. But sometimes people generate images which are ostensibly PPM except the image uses a different gamma transfer function than the one specified for PPM. A common case of this is when the image is created by simple hardware that doesn't have digital computational ability. Also, some simple programs that generate images from scratch do it with a gamma transfer in which the gamma value is 1.0. .sp \ .TP \fB-hist\fP Use this parameter to create a chunk that specifies the frequency (or histogram) of the colors in the image. .sp \ .TP \fB-text=\fP\fIfilename\fP This option lets you include arbitrary text strings in the PNG output, as tEXt chunks. .sp \fIfilename\fP is the name of a file that contains your text strings. .sp The output contains a distinct tEXt chunk for each entry in the file. .sp Here is an example of a text string file: .nf Title PNG file Author John Doe Description how to include a text chunk PNG file "Creation Date" 2015-may-11 Software pamtopng .fi .sp The file is divided into entries, each entry comprising consecutive lines of text. The first line of an entry starts in the first column (i.e. the first column is not white space) and every other line has white space in the first column. The first entry starts in the first line, so it is not valid for the first line of the file to have white space in its first column. .sp The first word in an entry is the key of the text string (e.g. 'Title'). It begins in column one of the line and continues up to, but not including, the first delimiter character or the end of the line, whichever is first. You can enclose the key in double quotes in which case the key can consists of multiple words. The quotes are not part of the key. The text string per se begins after the key and any delimiter characters after it, plus the text in subsequent continuation lines. .sp There is no limit on the length of a file line or entry or key or text string. There is no limit on the number of entries. .TP \fB-ztxt=\fP\fIfilename\fP The same as \fB-text\fP, except the text string is compressed in the PNG output. \fBpnmtopng\fP uses zTXt chunks instead of a tEXt chunks, unless the key for the text string starts with 'A' or 'T'. This odd exception exists for backward compatibility; we don't know why the program was originally designed this way, except that the distinction was meant to roughly identify the keys 'Author' and 'Title'. .sp \ .TP \fB-rgb=\fP\fIchroma_list\fP This option specifies how red, green, and blue component values of a pixel specify a particular color, by telling the chromaticities of those 3 primary illuminants and of white (i.e. full strength of all three). .sp The \fIchroma_list\fP value is a blank-separated list of 8 floating point decimal numbers: the CIE-1931 X and Y chromaticities (in that order) of each of white, red, green, and blue, in that order. .sp This information goes into the PNG's cHRM chunk. .sp In a shell command, make sure you use quotation marks so that the blanks in \fIchroma_list\fP don't make the shell see multiple command arguments. .sp This option was new in Netpbm 10.30 (October 2005). Before that, the option \fB-chroma\fP does the same thing, but with slightly different syntax. .TP \fB-size="\fP\fIx\fP \fIy\fP \fIunit\fP\fB"\fP This option determines the aspect ratio of the individual pixels of your image as well as the physical resolution of it. .sp \fIunit\fP is either \fB0\fP or \fI1\fP. When it is \fI1\fP, the option specifies the physical resolution of the image in pixels per meter. For example, \fB-size="10000 15000 1"\fP means that when someone displays the image, he should make it so that 10,000 pixels horizontally occupy 1 meter and 15,000 pixels vertically occupy one meter. And even if he doesn't take this advice on the overall size of the displayed image, he should at least make it so that each pixel displays as 1.5 times as high as wide. .sp When \fIunit\fP is \fB0\fP, that means there is no advice on the absolute physical resolution; just on the ratio of horizontal to vertical physical resolution. .sp This information goes into the PNG's pHYS chunk. .sp When you don't specify \fB-size\fP, \fBpnmtopng\fP creates the image with no pHYS chunk, which means square pixels of no absolute resolution. .sp This option was new in Netpbm 10.30 (October 2005). Before that, the option \fB-phys\fP does the same thing, but with slightly different syntax. .TP \fB-srgbintent=\fP\fIintent\fP This asserts that the input is a pseudo-Netpbm image that uses an sRGB color space (unlike true Netpbm) and indicates how you intend for the colors to be rendered. It causes \fBpnmtopng\fP to include an sRGB chunk in the PNG image that specifies that intent, so see the PNG documentation for more information on what this really means. .sp \fIintent\fP is one of: .IP \(bu \fBperceptual\fP .IP \(bu \fBrelativecolorimetric\fP .IP \(bu \fBsaturation\fP .IP \(bu \fBabsolutecolorimetric\fP .sp This option was new in Netpbm 10.71 (June 2015). Before that, \fBpnmtopng\fP never generates an sRGB chunk. .TP \fB-modtime="\fP[\fIyy\fP]\fIyy-mm-dd hh:mm:ss\fP\fB"\fP This option allows you to specify the modification time value to be placed in the PNG output. You can specify the year parameter either as a two digit or four digit value. .sp This option was new in Netpbm 10.30 (October 2005). Before that, the option \fB-time\fP does the same thing, but with slightly different syntax. .TP \fB-filter=\fP\fIn\fP This option is obsolete. Before Netpbm 10.22 (April 2004), this was the only way to specify a row filter. It specifies a single type of row filter, by number, that \fBpnmtopng\fP must use on each row. .sp Use \fB-nofilter\fP, \fB-sub\fP, \fB-up\fP, \fB-avg\fP, and \fB-paeth\fP in current Netpbm. .TP \fB-nofilter\fP .TP \fB-sub\fP .TP \fB-up\fP .TP \fB-avg\fP .TP \fB-paeth\fP Each of these options permits \fBpnmtopng\fP to use one type of row filter. \fBpnmtopng\fP chooses whichever of the permitted filters it finds to be optimal. If you specify none of these options, it is the same as specifying all of them -- \fBpnmtopng\fP uses any row filter type it finds optimal. .sp These options were new with Netpbm 10.22 (April 2004). Before that, you could use the \fB-filter\fP option to specify one permitted row filter type. The default, when you specify no filter options, was the same. .TP \fB-compression=\fP\fIn\fP This option sets set the compression level of the zlib compression. Select a level from 0 for no compression (maximum speed) to 9 for maximum compression (minimum speed). .sp The default is the default of the zlib library. .TP \fB-comp_mem_level=\fP\fIn\fP This option sets the memory usage level of the zlib compression. Select a level from 1 for minimum memory usage (and minimum speed) to 9 for maximum memory usage (and speed). .sp The default is the default of the zlib library. .sp This option was new in Netpbm 10.30 (October 2005). .TP \fB-comp_strategy=\fP{\fBhuffman_only\fP|\fBfiltered\fP} This options sets the compression strategy of the zlib compression. See Zlib documentation for information on what these strategies are. .sp The default is the default of the zlib library. .sp This option was new in Netpbm 10.30 (October 2005). .TP \fB-comp_method=\fP\fBdeflated\fP This option does nothing. It is here for mathematical completeness and for possible forward compatibility. It theoretically selects the compression method of the zlib compression, but the Z library knows only one method today, so there's nothing to choose. .sp The default is the default of the zlib library. .sp This option was new in Netpbm 10.30 (October 2005). .TP \fB-comp_window_bits=\fP\fIN\fP This option tells how big a window the zlib compression algorithm uses. The value is the base 2 logarithm of the window size in bytes, so 8 means 256 bytes. The value must be from 8 to 15 (i.e. 256 bytes to 32K). .sp See Zlib documentation for details on what this window size is. .sp The default is the default of the zlib library. .sp This option was new in Netpbm 10.30 (October 2005). .TP \fB-comp_buffer_size\fP=\fIN\fP This option determines in what size pieces \fBpnmtopng\fP does the zlib compression. One compressed piece goes in each IDAT chunk in the PNG. So the bigger this value, the fewer IDAT chunks your PNG will have. Theoretically, this makes the PNG smaller because 1) you have less per-IDAT-chunk overhead, and 2) the compression algorithm has more data to work with. But in reality, the difference will probably not be noticeable above about 8K, which is the default. .sp The value \fIn\fP is the size of the compressed piece (i.e. the compression buffer) in bytes. .sp This option was new in Netpbm 10.30 (October 2005). .TP \fB-force\fP When you specify this, \fBpnmtopng\fP limits its optimizations. The resulting PNG output is as similar to the Netpbm input as possible. For example, the PNG output will not be paletted and the transparency channel will be represented as a full transparency channel even if the information could be represented more succinctly with a transparency chunk. .sp \ .TP \fB-libversion\fP This option causes \fBpnmtopng\fP to display version information about itself and the libraries it uses, \fBin addition to all its normal function\fP. Do not confuse this with the Netpbm common option \fB-version\fP, which causes the program to display version information about the Netpbm library and do nothing else. .sp You can't really use this option in a program that invokes \fBpnmtopng\fP and needs to know which version it is. Its function has changed too much over the history of \fBpnmtopng\fP. The option is good only for human eyes. .UN seealso .SH SEE ALSO .BR "pngtopam" (1)\c \&, .BR "pamtopng" (1)\c \&, .BR "pnmremap" (1)\c \&, .BR "pnmgamma" (1)\c \&, .BR "pnm" (1)\c \& .PP For information on the PNG format, see .UR http://schaik.com/png http://schaik.com/png .UE \&. .UN author .SH AUTHOR Copyright (C) 1995-1997 by Alexander Lehmann and Willem van Schaik. .SH DOCUMENT SOURCE This manual page was generated by the Netpbm tool 'makeman' from HTML source. The master documentation is at .IP .B http://netpbm.sourceforge.net/doc/pnmtopng.html .PP