pamtopng

Updated: 28 June 2015
Table Of Contents

NAME

pamtopng - convert a Netpbm image to PNG

SYNOPSIS

pamtopng [-verbose] [-transparent=color] [-background=color] [-gamma=value] [-chroma="wx wy rx ry gx gy bx by"] [-srgbintent=intent] [-time=[yy]yy-mm-dd hh:mm:ss] [-text=file] [-ztxt=file] [-itxt=file] [pnmfile]

Minimum unique abbreviation of option is acceptable. You may use double hyphens instead of a single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value.

DESCRIPTION

This program is part of Netpbm.

pamtopng reads a Netpbm image as input and produces a PNG image as output.

Color component values in PNG files are either 8 or 16 bits wide, so where necessary pamtopng scales colors to have a maxval of 255 or 65535. In that case, it will add an sBIT chunk to indicated the original bit-depth.

pamtopng works only on images with maxval 1, 3, 15, 255, or 65535. You can use pamdepth to convert an image with some other maxval to one of these.

pamtopng produces a color PNG from a color PAM, even if the only colors in the image are shades of gray. To create a graycale PNG, from such an image (which might be slightly smaller), you can use other Netpbm programs to convert the input to grayscale.

Alternative: pnmtopng

Netpbm contains another program for generating PNG images: pnmtopng. pnmtopng is a much older program - it is in fact the first program in the world that could generate a PNG. pnmtopng is a complex, feature-laden program. It lets you control various arcane aspects of the conversion and create PNGs with various arcane features. It does various transformations on the image to create the greatest compression possible, to a degree that probably doesn't make any difference in the modern world.

Because pnmtopng has been around virtually forever, programs and procedures that use it are more portable than those that use pamtopng. Its age and popularity also probably make it have fewer bugs.

pamtopng does not have any way to do what the following do in pnmtopng:

These are some of the other functions of pnmtopng that pamtopng lacks:

Features that exist in both programs are controlled by largely the same command syntax. But there are these differences:

OPTIONS

-transparent=color
pamtopng marks the specified color as transparent in the PNG image.

Specify the color (color) as described for the argument of the ppm_parsecolor() library routine. E.g. red or rgb:ff/00/0d.

-background=color
This causes pamtopng to create a background color chunk in the PNG output which can be used for subsequent transparency channel or transparent color conversions. Specify color the same as for -transparent.
-gamma=value
This causes pnmtopng 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 -gamma=.45. 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.
-chroma=chroma_list
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).

The chroma_list 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.

This information goes into the PNG's cHRM chunk.

In a shell command, make sure you use quotation marks so that the blanks in chroma_list don't make the shell see multiple command arguments.

-srgbintent=intent
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 pamtopng 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.

intent is one of:

-text=filename
This option lets you include comments in text chunks of the PNG output. filename is the name of a file that contains your text comments.

The output contains a distinct tEXt chunk for each comment.

Here is an example of a comment file:

	Title           PNG file
	Author          John Doe
	Description     how to include a text chunk
                        PNG file
	"Creation Date" 2015-may-11
	Software        pamtopng

The first line representing a comment must not start with a delimiter character (a blank, tab or null). Every other line in the group is a continuation line and must start with a delimiter character.

The first word in a comment line is the keyword of the comment. 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 keyword in double quotes in which case the keyword can consists of multiple words. The quotes are not part of the keyword. The comment text begins after the keyword and any delimiter characters after it, plus the text in subsequent continuation lines.

There is no limit on the length of a file line or keyword or comment text line or comment text. There is no limit on the number of comments, the size of the comment or the number of comments in the file.

-ztxt=filename
The same as -text, except pamtopng will compress the comment, except that when the keyword is "Title", "Author" or "Language".
-itxt=filename
Similar to -text, but the comments can be in a language other than English. The PNG image indicates what language that is and includes the comment key both in English and that language.

The input file must start with a record that identifies the comment language. Its key is "Language".

For each record, you must give the key both in English and in the comment language.

Example:

	Language        Taal             nl-NL
        Title           Titel            PNG file
        Author          Auteur           Pietje Puk
        Description     Omschrijving     Tekst in het Nederlands.

The language specification is based on the ISO 639-1 standard, see http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for the valid codes. The format is either a two character "nl" or an extended code like "en-US".

-time="[yy]yy-mm-dd hh:mm:ss"
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 or four digit value.
-verbose
This causes the program to display various facts about the conversion.

SEE ALSO

pngtopam, pnmtopng, pam, pnm

For information on the PNG format, see http://www.w3.org/TR/PNG/, http://libpng.org/pub/png/, http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes and http://schaik.com/png/.

HISTORY

pamtopng was new in Netpbm 10.70 (June 2015).

Before pamtopng, the two ways to create PNG images with Netpbm were pnmtopng and pamrgbatopng. The history of the former is discussed above. The latter was added to Netpbm in 2005 as a cheap way to fill a significant need that pnmtopng did not: the ability to turn the alpha channel in a PAM image into the alpha channel in a PNG image.

Handling of the alpha channel with pnmtopng is very cumbersome (as was dealing with alpha channels in general before the introduction of the PAM format). pamrgbatopng could do what people wanted with the alpha channel, but nothing else. It was a very small program with literally no command line options.

The goal in those days was eventually to expand pnmtopng to do the PAM alpha channel thing, rename it to pamtopng, and retire pamrgbatopng. But pnmtopng is such a complex program, because of its dizzying array of features and its need for backward compatibility, that adding that one capability to it was a daunting task and for ten years nobody attempted it.

In 2015, one of the authors of the original pnmtopng (from before it was even part of Netpbm -- a program that shared essentially no lines of code with pnmtopng of 2015) decided to go in a different direction. While many features of pnmtopng were pretty important and easy to implement, many others were probably of no use in the modern world or at least not important enough to justify the complexity they lent to the code. (The features thought to be outdated were ones that were intended to make the PNG output slightly smaller - something considerably less important with the declining cost of computer resources).

And there was an opportunity to drop those features: We could use the new name "pamtopng" for a new program, keep the existing program under the name "pnmtopng", and avoid most backward compatibility trouble.

Therefore, Willem van Schaik wrote an intermediate level program that had all the most important features of pnmtopng, plus the alpha channel handling of pamrgbatopng, with nice, simple code. That was pamtopng.

Because pamrgbatopng had no options, pamtopng was backward compatible with it without even trying. Therefore, as soon as we added pamtopng to Netpbm, we removed pamrgbatopng and recommended that pamtorgbatopng be installed as an alias for pamtopng.

AUTHOR

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

Table Of Contents