{
    "mode": "man",
    "parameter": "pam",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/pam/5/json",
    "generated": "2026-10-06T07:23:29Z",
    "sections": {
        "NAME": {
            "content": "pam - Netpbm common 2-dimensional bitmap format\n\n",
            "subsections": []
        },
        "GENERAL": {
            "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\nThe  name  \"PAM\"  is  an acronym derived from \"Portable Arbitrary Map.\" This derivation makes\nmore sense if you consider it in the context of the other Netpbm format names: PBM, PGM,  and\nPPM.\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 called the maxval.  The maxval is the same for every sample in the image.   The\ntwo  dimensional  array  of  all the Nth samples of each tuple is called the Nth plane or Nth\nchannel of the image.\n\nThough the basic format does not assign any meaning to the tuple values, it does  include  an\noptional  string  that describes that meaning.  The contents of this string, called the tuple\ntype, are arbitrary from the point of view of the basic PAM format, but users of  the  format\nmay  assign meaning to it by convention so they can identify their particular implementations\nof the PAM format.  Some tuple types are defined as official subformats of PAM.  See  Defined\nTuple Types .\n\n",
            "subsections": []
        },
        "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 even a new pro‐\ngram must work with them.  Having the library handle all the formats makes it  convenient  to\nwrite programs that use the newer PAM format as well.\n\n",
            "subsections": []
        },
        "THE LAYOUT": {
            "content": "A  convenient  way to read and write the PAM format accurately is via the libnetpbm(1) C sub‐\nroutine library.\n\nA 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\n\nP7\nWIDTH 227\nHEIGHT 149\nDEPTH 3\nMAXVAL 255\nTUPLTYPE RGB\nENDHDR\n\n\n\nThe header begins with the ASCII characters \"P7\" followed by newline.  This is the magic num‐\nber.\n\nNote: xv thumbnail images also start with the \"P7\" magic number.  (This and PAM were indepen‐\ndent  extensions to the Netpbm formats).  The rest of the format makes it easy to distinguish\nPAM from that format, though).\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\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\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.  There must be  something  other\nthan white space after the TUPLTYPE token.\n\nIf  there  are  multiple TUPLTYPE header lines, the tuple type is the concatenation of\nthe values from each of them, separated by a single blank, in the order in which  they\nappear  in  the  header.   If there are no TUPLTYPE header lines the tuple type is the\nnull string.\n\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\nThe character referred to as \"newline\" herein is the character known in ASCII as Line Feed or\nLF.\n\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "Height, width, depth, and maxval are at least 1.\n\nHeight, width, and depth have no defined maximum, but processors  and  generators  of  images\nusually have their own limitations.\n\nThe  maxval of an image is never greater than 65535.  (The reason it is limited is to make it\neasier to build an image processor, in which intermediate arithmetic values often have to fit\nwithin 31 or 32 bits).  There was no specified limitation before October,  2005,  but  essen‐\ntially all implementations have always observed it.\n\n",
            "subsections": []
        },
        "DEFINED TUPLE TYPES": {
            "content": "Some  tuple types are defined in this specification to specify official subformats of PAM for\nespecially popular applications of the format.  Users of the format may also define their own\ntuple types, and thus their own subformats.\n\nTuple type affects only the meanings of the samples (which are unsigned integers) in the  tu‐\nples of the image.  It does not affect how the samples or tuples are encoded.  Tuple type may\naffect the meaning of a tuple's position in the array (e.g. it may indicate in a visual image\nthat a tuple in Row 1 is one at the top of the image rather than the bottom).\n\nTuple  type  never  determines how many samples are in a tuple (that is instead determined by\nthe DEPTH header line).  Tuple type could be said to imply a depth (number of samples per tu‐\nple) because certain tuple types are valid only in combination with certain DEPTH values, but\nit is good programming practice to use DEPTH for the depth when decoding the raster and sepa‐\nrately validate that the depth is consistent with the tuple type.  Also, it is good  practice\nto accept a depth that is too great and just ignore the higher numbered planes.\n\n",
            "subsections": [
                {
                    "name": "PAM Used For Visual Images",
                    "content": "A common use of PAM images is to represent visual images such as are typically represented by\nimages in the older and more concrete PBM, PGM, and PPM formats.\n"
                },
                {
                    "name": "Black And White",
                    "content": "A black and white image, such as would alternatively be represented by a PBM image, has a tu‐\nple  type  of  \"BLACKANDWHITE\".  Such a PAM image has a depth of 1 and maxval 1 where the one\nsample in each tuple is 0 to represent a black pixel and 1 to represent  a  white  one.   The\nmaxval,  height,  width,  and  order of tuples in the raster bear the obvious relationship to\nthose of the equivalent PGM image.\n\nNote that in the PBM format, a sample value of zero means  white,  but  in  PAM,  zero  means\nblack.\n"
                },
                {
                    "name": "Grayscale",
                    "content": "A  grayscale  image,  such  as would alternatively be represented by a PGM image, has a tuple\ntype of \"GRAYSCALE\".  Such a PAM image has a depth of 1.   The  maxval,  height,  width,  and\nraster bear the obvious relationship to those of the equivalent PGM image.\n"
                },
                {
                    "name": "Color",
                    "content": "A color image, such as would alternatively be represented by a PPM image, has a tuple type of\n\"RGB\".   Such  a  PAM image has a depth of 3.  The maxval, height, width, and raster bear the\nobvious relationship to those of the PPM image.  The first plane represents red,  the  second\ngreen, and the third blue.\n"
                },
                {
                    "name": "Transparent",
                    "content": "Each  of  the visual image formats mentioned above has a variation that contains transparency\ninformation.  In that variation, the tuple type has \"ALPHA\" added to it  (e.g.  \"RGBALPHA\")\nand one more plane.  The highest numbered plane is the opacity plane (sometimes called an al‐\npha plane or transparency plane).\n\nIn  this  kind of image, the color represented by a pixel is actually a combination of an ex‐\nplicitly specified foreground color and a background color to be identified later.\n\nThe planes other than the opacity plane describe the foreground color.  A sample in the opac‐\nity plane tells how opaque the pixel is, by telling what fraction of the pixel's light  comes\nfrom  the foreground color.  The rest of the pixel's light comes from the (unspecified) back‐\nground color.\n\nFor example, in a GRAYSCALEALPHA image, assume Plane 0 indicates a gray tone  60%  of  white\nand  Plane  1  indicates  opacity 25%.  The foreground color is the 60% gray, and 25% of that\ncontributes to the ultimate color of the pixel.  The other 75%  comes  from  some  background\ncolor.   So  let's assume further that the background color of the pixel is full white.  Then\nthe color of the pixel is 90% of white:  25% of the foreground 60%, plus  75%  of  the  back‐\nground 100%.\n\nThe  sample  value is the opacity fraction just described, as a fraction of the maxval.  Note\nthat it is not gamma-adjusted like the foreground color samples.\n\n\n"
                }
            ]
        },
        "INTERNET MEDIA TYPE": {
            "content": "No Internet Media Type (aka MIME type, content type) for PBM has been registered  with  IANA,\nbut  the unofficial value image/x-portable-arbitrarymap is assigned by this specification, to\nbe consistent with conventional values for the older Netpbm formats.\n\n",
            "subsections": []
        },
        "FILE NAME": {
            "content": "The conventional suffix for the name of a PAM file is \".pam\".  But this is not required.\n\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Netpbm(1), pbm(1), pgm(1), ppm(1), pnm(1), libnetpbm(1)\n",
            "subsections": []
        },
        "DOCUMENT SOURCE": {
            "content": "This manual page was generated by the Netpbm tool 'makeman' from  HTML  source.   The  master\ndocumentation is at\n\nhttp://netpbm.sourceforge.net/doc/pam.html\n\nnetpbm documentation                      27 November 2013               PAM format specification(5)",
            "subsections": []
        }
    },
    "summary": "pam - Netpbm common 2-dimensional bitmap format",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "Netpbm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/Netpbm/1/json"
        },
        {
            "name": "pbm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pbm/1/json"
        },
        {
            "name": "pgm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pgm/1/json"
        },
        {
            "name": "ppm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ppm/1/json"
        },
        {
            "name": "pnm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/1/json"
        },
        {
            "name": "libnetpbm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/libnetpbm/1/json"
        }
    ]
}