{
    "mode": "man",
    "parameter": "pnmtopng",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pnmtopng/1/json",
    "generated": "2026-05-30T05:16:04Z",
    "synopsis": "pnmtopng [-verbose] [-downscale] [-interlace] [-alpha file]\n[-transparent [=]color] [-background color] [-gamma value]\n[-hist] [-chroma wx wy rx ry gx gy bx by] [-phys x y unit]\n[-text file] [-ztxt file] [-time [yy]yy-mm-dd hh:mm:ss]\n[-filter type] [-compression level] [-force] [pnmfile]",
    "sections": {
        "NAME": {
            "content": "pnmtopng - convert a portable anymap into a Portable Network Graphics file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pnmtopng [-verbose] [-downscale] [-interlace] [-alpha file]\n[-transparent [=]color] [-background color] [-gamma value]\n[-hist] [-chroma wx wy rx ry gx gy bx by] [-phys x y unit]\n[-text file] [-ztxt file] [-time [yy]yy-mm-dd hh:mm:ss]\n[-filter type] [-compression level] [-force] [pnmfile]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Reads a portable pixmap as input.  Produces a Portable Network Graphics file as output.\n\nColor  values  in PNG files are either eight or sixteen bits wide, so pnmtopng will automati‐\ncally scale colors to have a maxval of 255 or 65535.  Grayscale files will be  produced  with\nbit depths 1, 2, 4, 8 or 16.  An extra pnmdepth step is not necessary.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-verbose",
                    "content": "Display the format of the output file.\n"
                },
                {
                    "name": "-downscale",
                    "content": "Enables  scaling  of  maxvalues of more then 65535 to 16 bit. Since this means loss of\nimage data, the step is not performed by default.\n"
                },
                {
                    "name": "-interlace",
                    "content": "Creates an interlaced PNG file (Adam7).\n"
                },
                {
                    "name": "-alpha file",
                    "content": "The alpha channel of pixel (or image) specifies the transparency of a pixel.  To  cre‐\nate  this  fourth  pixel  value  a separate .pbm- or .pgm-file is needed. In this file\nblack (0) stands for fully transparant and white (1) will become opaque. The sizes  of\nboth  pbm/pgm/ppm-files  must  be the same.  If the information contained in the alpha\nmask can also be represented as a transparency index, it  will  be  used,  since  this\nshould result in a smaller image file.\n"
                },
                {
                    "name": "-transparent color",
                    "content": "ppmtogif marks the specified color as transparent in the PNG image.\n\nYou  specify  the  color as in ppmmake(1).E.g.  red or rgb:ff/00/0d.  If the color you\nspecify is not present in the image, pnmtopnm selects instead the color in  the  image\nthat is closest to the one you specify.  Closeness is measured as a cartesian distance\nbetween colors in RGB space.  If multiple colors are equidistant, pnmtopnm chooses one\nof them arbitrarily.\n\nHowever, if you prefix your color specification with \"=\", e.g.\n\n-transparent =red\n\nOnly  the  exact color you specify will be transparent.  If that color does not appear\nin the image, there will be no transparency.  pnmtopng issues an  information  message\nwhen this is the case.\n\n\n"
                },
                {
                    "name": "-background color",
                    "content": "To  create a background color chunck in the png-file, which can be used for subsequent\nalpha-channel or transparent-color conversions. See -transparent for format of color.\n"
                },
                {
                    "name": "-gamma value",
                    "content": "Creates an gAMA chunk. By providing the gamma-value of the pnm-file the software  that\nlateron  will display the png-file will be able to do the necessary gamma-corrections.\nA good rule-of-thumb is that when the file is created by a software  program  (like  a\nCAD-program  or  a ray-tracer) the value is probably 1.0. When the pnm-file looks good\non a non-gamma corrected PC display (which has itself a gamma-value of 2.2 -  2.8),  a\nvalue of 0.45 should be given.\n"
                },
                {
                    "name": "-hist",
                    "content": "the colors in the image.\n"
                },
                {
                    "name": "-chroma white point X and Y, red X and Y, green X and Y, and blue X and Y",
                    "content": "To specify the white point and rgb values following the CIE-1931 spec.\n"
                },
                {
                    "name": "-phys x y unit",
                    "content": "When your image should not be displayed with square but with rectangular  pixels  this\noption  should  be  used  to create a pHYS chunk. When the unit-value is 0 the x and y\nonly gives the ratio of pixel width and height. When it is 1 the x and y  specify  the\nnumber of pixels per meter.\n"
                },
                {
                    "name": "-text file",
                    "content": "Allows to include comments in the text-chunk of the png-file.  The format of the text-\nfile is as follows: when the first column does not contain a blank or a tab, the first\nword is considered to be the keyword.  For keywords to contain spaces, enclose them in\ndouble-quotes.\nWhen the first character on a line is a blank or tab, the rest of the line  is  a  new\nline  of  the  current comment.  Note that the initial spaces are not considered to be\npart of the comment line.\n\nHere is an example:\n-------------------------------------------\nTitle           PNG-file\nAuthor          your name\nDescription     how to include a text-chunk\ninto a PNG file\n\"Creation date\" 3-feb-1987\nSoftware        pnmtopng\n-------------------------------------------\n"
                },
                {
                    "name": "-ztxt file",
                    "content": "The same as -text, but now the text will be compressed.\n"
                },
                {
                    "name": "-time yy-mm-dd hh:mm:ss or -time yyyy-mm-dd hh:mm:ss",
                    "content": "This option allows you to specify the (modification)time. The year  parameter  can  be\ngiven as a two- or a four-digit value.\n"
                },
                {
                    "name": "-filter type",
                    "content": "When  the  types  of  filters must be restricted you can specify here which filter you\nwant to use. Allowed values are: 0 (none), 1 (sub), 2 (up), 3 (avg) and 4 (paeth).\n"
                },
                {
                    "name": "-compression level",
                    "content": "To explicitly set the compression level of zlib use this parameter. Select a level be‐\ntween 0 for no compression (max speed) and 9 for maximum compression.\n"
                },
                {
                    "name": "-force",
                    "content": "input is as much as possible enforced. For example no paletted files will  be  created\nand alpha-channel images will not be converted to images with a transparency chunck.\n\nAll flags can be abbreviated to their shortest unique prefix.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "pngtopnm(1), gif2png(1), pnmgamma(1), pnm(5)\n",
            "subsections": []
        },
        "NOTE": {
            "content": "Instead  of  xxxtopnm|pnmtopng,  a  specific  converter  should  be used, if available.  E.g.\ngif2png (GIF conversion), etc.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "There could be an option to read the comment text from pnm comments  instead  of  a  separate\nfile.\n\nThe program could be much faster, with a bit of code optimizing.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Copyright (C) 1995-1997 by Alexander Lehmann\nand Willem van Schaik.\n\n\n\n6 January 1997                                pnmtopng(1)",
            "subsections": []
        }
    },
    "summary": "pnmtopng - convert a portable anymap into a Portable Network Graphics file",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Display the format of the output file."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Enables scaling of maxvalues of more then 65535 to 16 bit. Since this means loss of image data, the step is not performed by default."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Creates an interlaced PNG file (Adam7)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The alpha channel of pixel (or image) specifies the transparency of a pixel. To cre‐ ate this fourth pixel value a separate .pbm- or .pgm-file is needed. In this file black (0) stands for fully transparant and white (1) will become opaque. The sizes of both pbm/pgm/ppm-files must be the same. If the information contained in the alpha mask can also be represented as a transparency index, it will be used, since this should result in a smaller image file."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "ppmtogif marks the specified color as transparent in the PNG image. You specify the color as in ppmmake(1).E.g. red or rgb:ff/00/0d. If the color you specify is not present in the image, pnmtopnm 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, pnmtopnm chooses one of them arbitrarily. However, if you prefix your color specification with \"=\", e.g. -transparent =red Only the exact color you specify will be transparent. If that color does not appear in the image, there will be no transparency. pnmtopng issues an information message when this is the case."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "To create a background color chunck in the png-file, which can be used for subsequent alpha-channel or transparent-color conversions. See -transparent for format of color."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Creates an gAMA chunk. By providing the gamma-value of the pnm-file the software that lateron will display the png-file will be able to do the necessary gamma-corrections. A good rule-of-thumb is that when the file is created by a software program (like a CAD-program or a ray-tracer) the value is probably 1.0. When the pnm-file looks good on a non-gamma corrected PC display (which has itself a gamma-value of 2.2 - 2.8), a value of 0.45 should be given."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "the colors in the image."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "To specify the white point and rgb values following the CIE-1931 spec."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "When your image should not be displayed with square but with rectangular pixels this option should be used to create a pHYS chunk. When the unit-value is 0 the x and y only gives the ratio of pixel width and height. When it is 1 the x and y specify the number of pixels per meter."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Allows to include comments in the text-chunk of the png-file. The format of the text- file is as follows: when the first column does not contain a blank or a tab, the first word is considered to be the keyword. For keywords to contain spaces, enclose them in double-quotes. When the first character on a line is a blank or tab, the rest of the line is a new line of the current comment. Note that the initial spaces are not considered to be part of the comment line. Here is an example: ------------------------------------------- Title PNG-file Author your name Description how to include a text-chunk into a PNG file \"Creation date\" 3-feb-1987 Software pnmtopng -------------------------------------------"
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The same as -text, but now the text will be compressed."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option allows you to specify the (modification)time. The year parameter can be given as a two- or a four-digit value."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "When the types of filters must be restricted you can specify here which filter you want to use. Allowed values are: 0 (none), 1 (sub), 2 (up), 3 (avg) and 4 (paeth)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "To explicitly set the compression level of zlib use this parameter. Select a level be‐ tween 0 for no compression (max speed) and 9 for maximum compression."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "input is as much as possible enforced. For example no paletted files will be created and alpha-channel images will not be converted to images with a transparency chunck. All flags can be abbreviated to their shortest unique prefix."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "pngtopnm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pngtopnm/1/json"
        },
        {
            "name": "gif2png",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/gif2png/1/json"
        },
        {
            "name": "pnmgamma",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmgamma/1/json"
        },
        {
            "name": "pnm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/5/json"
        }
    ]
}