{
    "mode": "man",
    "parameter": "pam",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/pam/5/json",
    "generated": "2026-06-14T13:03:46Z",
    "sections": {
        "NAME": {
            "content": "pam - portable arbitrary map file format\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The PAM image format is a lowest common denominator 2 dimensional map format.\n\nIt  is designed to be used for any of myriad kinds of graphics, but can theoretically be used\nfor any kind of data that is arranged as a two dimensional rectangular array.  Actually, from\nanother  perspective  it can be seen as a format for data arranged as a three dimensional ar‐\nray.\n\nThis format does not define the meaning of the data at any particular point in the array.  It\ncould  be  red, green, and blue light intensities such that the array represents a visual im‐\nage, or it could be the same red, green, and blue components plus a  transparency  component,\nor  it  could  contain  annual rainfalls for places on the surface of the Earth.  Any process\nthat uses the PAM format must further define the format to specify the meanings of the data.\n\nA PAM image describes a two dimensional grid of tuples.  The tuples are arranged in rows  and\ncolumns.   The  width  of the image is the number of columns.  The height of the image is the\nnumber of rows.  All rows are the same width and all columns are the same height.  The tuples\nmay have any degree, but all tuples have the same degree.  The degree of the tuples is called\nthe depth of the image.  Each member of a tuple is called a sample.  A sample is an  unsigned\ninteger  which  represents  a  locus along a scale which starts at zero and ends at a certain\nmaximum value greater than zero called the maxval.  The maxval is the same for  every  sample\nin  the  image.  The two dimensional array of all the Nth samples of each tuple is called the\nNth plane or Nth channel of the image.\n\nThough the format does not assign any meaning to the tuple values, it  does  include  an  op‐\ntional  string  that  describes  that meaning.  The contents of this string, called the tuple\ntype, are arbitrary from the point of view of the PAM format, but users of the format may as‐\nsign meaning to it by convention so they can identify their particular implementations of the\nPAM format.\n\n",
            "subsections": [
                {
                    "name": "The Layout",
                    "content": "A PAM file consists of a sequence of one or more PAM images.  There are no data,  delimiters,\nor padding before, after, or between images.\n\nEach PAM image consists of a header followed immediately by a raster.\n\nHere is an example header:\n\nP7\nWIDTH 227\nHEIGHT 149\nDEPTH 3\nMAXVAL 255\nTUPLTYPE RGB\nENDHDR\n\nThe header begins with the ASCII characters \"P7\" followed by newline.  This is the magic num‐\nber.\n\nThe header continues with an arbitrary number of lines of ASCII text.  Each  line  ends  with\nand is delimited by a newline character.\n\nEach header line consists of zero or more whitespace-delimited tokens or begins with \"#\".  If\nit begins with \"#\" it is a comment and the rest of this specification does not apply to it.\n\nA header line which has zero tokens is valid but has no meaning.\n\nThe type of header line is identified by its first token, which is 8 characters or less:\n\n\nENDHDR This is the last line in the header.  The header must contain  exactly  one  of  these\nheader lines.\n\n\nHEIGHT The  second  token is a decimal number representing the height of the image (number of\nrows).  The header must contain exactly one of these header lines.\n\n\nWIDTH  The second token is a decimal number representing the width of the  image  (number  of\ncolumns).  The header must contain exactly one of these header lines.\n\n\nDEPTH  The  second  token  is a decimal number representing the depth of the image (number of\nplanes or channels).  The header must contain exactly one of these header lines.\n\n\nMAXVAL The second token is a decimal number representing the maxval of the image.  The header\nmust contain exactly one of these header lines.\n\n\n\nTUPLTYPE\nThe  header may contain any number of these header lines, including zero.  The rest of\nthe line is part of the tuple type.  The rest of the line is not  tokenized,  but  the\ntuple  type  does not include any white space immediately following TUPLTYPE or at the\nvery end of the line.  It does not include a newline.  If there are multiple  TUPLTYPE\nheader  lines,  the  tuple  type is the concatenation of the values from each of them,\nseparated by a single blank, in the order in which they  appear  in  the  header.   If\nthere are no TUPLTYPE header lines the tuple type is the null string.\n\n\nThe  raster  consists of each row of the image, in order from top to bottom, consecutive with\nno delimiter of any kind between, before, or after, rows.\n\nEach row consists of every tuple in the row, in order from left to right, consecutive with no\ndelimiter of any kind between, before, or after, tuples.\n\nEach  tuple consists of every sample in the tuple, in order, consecutive with no delimiter of\nany kind between, before, or after, samples.\n\nEach sample consists of an unsigned integer in pure binary format, with the most  significant\nbyte  first.   The  number  of bytes is the minimum number of bytes required to represent the\nmaxval of the image.\n\n\n"
                },
                {
                    "name": "PAM Used For PNM (PBM, PGM, or PPM) Images",
                    "content": "A common use of PAM images is to represent the older and more concrete PBM, PGM, and PPM  im‐\nages.\n\nA  PBM  image is conventionally represented as a PAM image of depth 1 with maxval 1 where the\none sample in each tuple is 0 to represent a black pixel and 1 to represent a white one.  The\nheight, width, and raster bear the obvious relationship to those of the PBM image.  The tuple\ntype for PBM images represented as PAM images is conventionally \"BLACKANDWHITE\".\n\nA PGM image is conventionally represented as a PAM image of depth  1.   The  maxval,  height,\nwidth,  and  raster  bear the obvious relationship to those of the PGM image.  The tuple type\nfor PGM images represented as PAM images is conventionally \"GRAYSCALE\".\n\nA PPM image is conventionally represented as a PAM image of depth  3.   The  maxval,  height,\nwidth,  and  raster bear the obvious relationship to those of the PPM image.  The first plane\nrepresents red, the second green, and the third blue.  The tuple type for PPM  images  repre‐\nsented as PAM images is conventionally \"RGB\".\n\n"
                },
                {
                    "name": "The Confusing Universe of Netpbm Formats",
                    "content": "It  is  easy to get confused about the relationship between the PAM format and PBM, PGM, PPM,\nand PNM.  Here is a little enlightenment:\n\n\"PNM\" is not really a format.  It is a shorthand for the PBM, PGM, and  PPM  formats  collec‐\ntively.   It  is also the name of a group of library functions that can each handle all three\nof those formats.\n\n\"PAM\" is in fact a fourth format.  But it is so general that you can represent the  same  in‐\nformation  in a PAM image as you can in a PBM, PGM, or PPM image.  And in fact a program that\nis designed to read PBM, PGM, or PPM and does so with a recent version of the Netpbm library,\nwill read an equivalent PAM image just fine and the program will never know the difference.\n\nTo  confuse things more, there is a collection of library routines called the \"pam\" functions\nthat read and write the PAM format, but also read and write the PBM, PGM,  and  PPM  formats.\nThey  do  this  because  the latter formats are much older and more popular, so this makes it\nconvenient to write programs that use the newer PAM format.\n\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "pbm(5), pgm(5), ppm(5), pnm(5), libpnm(3)\n\n\n\n31 July 2000                                      pam(5)",
            "subsections": []
        }
    },
    "summary": "pam - portable arbitrary map file format",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "pbm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pbm/5/json"
        },
        {
            "name": "pgm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pgm/5/json"
        },
        {
            "name": "ppm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/ppm/5/json"
        },
        {
            "name": "pnm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/5/json"
        },
        {
            "name": "libpnm",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/libpnm/3/json"
        }
    ]
}