{
    "mode": "man",
    "parameter": "pnmmontage",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pnmmontage/1/json",
    "generated": "2026-09-24T02:18:40Z",
    "synopsis": "",
    "sections": {
        "NAME": {
            "content": "pnmmontage - create a montage of PNM images\n\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "",
            "subsections": [
                {
                    "name": "pnmmontage",
                    "content": "[-header=headerfile]\n\n[-quality=n]\n\n[-prefix=prefix]\n\n[-0|-1|-2|...|-9]\n\n[-data=filename]\n\npnmfile...\n\n"
                }
            ]
        },
        "DESCRIPTION": {
            "content": "This program is part of Netpbm(1).\n\npnmmontage packs images of differing sizes into a minimum-area composite image.\n\nAreas of the output that cannot be occupied by an image are black.\n\n\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "In  addition  to  the options common to all programs based on libnetpbm (most notably -quiet,\nsee \u001b]8;;index.html#commonoptions\u001b\\ Common Options\u001b]8;;\u001b\\ ), pnmmontage recognizes the following command line options:\n\n\n\n",
            "subsections": [
                {
                    "name": "-data=_",
                    "content": "This option causes pnmmontage to write a file that describes in machine-readable  form\nthe positions of the original images within the packed image.  Here is an example:\n\n\n:0:0:227:298\n../image1.ppm:0:0:227:149\n../image2.ppm:0:149:227:149\n\n\n\nThere is a line for each component image and one for the composite.\n\nThe 5 fields on each line are:\n\n\n\n•      source image name (or null string indicating the line for the composite image)\n\n•      Column number of upper left corner of the image\n\n•      Row number of upper left corner of the image\n\n•      width of the image (columns)\n\n•      height of the image (rows)\n\n\nThis option was new in Netpbm 10.6 (July 2002).\n\n"
                },
                {
                    "name": "-header=_",
                    "content": "Tells  pnmmontage  to  write  a  C header file of the locations of the original images\nwithin the packed image.  Each original  image  generates  four  #defines  within  the\npacked  file:  xxxX, xxxY, xxxSZX, and xxxSZY, where xxx is the name of the file, con‐\nverted to all uppercase.  The output also includes  #defines  OVERALLX  and  OVERALLY,\nwhich specifies the total size of the montage image.\n\nHere is an example:\n\n#define OVERALLX 227\n#define OVERALLY 298\n\n#define X 0\n#define Y 0\n#define SZX 227\n#define SZY 149\n\n#define X 0\n#define Y 149\n#define SZX 227\n#define SZY 149\n\n\n"
                },
                {
                    "name": "-prefix",
                    "content": "Tells pnmmontage to use the specified prefix on all of the #defines it generates.\n\n"
                },
                {
                    "name": "-quality",
                    "content": "Before attempting to place the subimages, pnmmontage will calculate a minimum possible\narea  for  the montage; this is either the total of the areas of all the subimages, or\nthe width of the widest subimage times the height of the tallest  subimage,  whichever\nis  greater.   pnmmontage then initiates a problem-space search to find the best pack‐\ning; if it finds a solution that is (at least) as good as the minimum area  times  the\nquality  as  a percent, it will break out of the search.  Thus, -quality=100 will find\nthe best possible solution; however, it may take a very long time to do so.   The  de‐\nfault is -quality=200.\n\n"
                },
                {
                    "name": "-0 -1 -9",
                    "content": "These  options  control  the  quality at a higher level than -quality; -0 is the worst\nquality (pick the first solution found), while -9 is the best quality (perform an  ex‐\nhaustive  search of problem space for the absolute best packing).  The higher the num‐\nber, the slower the computation.  The default is -5.\n\n\n\n\n",
                    "flag": "-9"
                }
            ]
        },
        "NOTES": {
            "content": "Using -9 is very slow on all but the smallest image sets.\n\nThe minimum area arrangement is often not a convenient shape.  For example,  it  might  be  a\ntall,  thin column of images, when you'd rather have something more square.  To force a mini‐\nmum width or height, you can include a strut image - a black image that wide  and  one  pixel\nhigh.  Similarly, you can use a vertical strut to force a minimum height.\n\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pamcat(1), pnmindex(1), pnm(1), pam(1), pbm(1), pgm(1), ppm(1)\n\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "pnmmontage was new in Netpbm 9.10 (January 2001).\n\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright (C) 2000 by Ben Olmstead.\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/pnmmontage.html\n\nnetpbm documentation                      22 November 2012                 Pnmmontage User Manual(1)",
            "subsections": []
        }
    },
    "summary": "pnmmontage - create a montage of PNM images",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option causes pnmmontage to write a file that describes in machine-readable form the positions of the original images within the packed image. Here is an example: :0:0:227:298 ../image1.ppm:0:0:227:149 ../image2.ppm:0:149:227:149 There is a line for each component image and one for the composite. The 5 fields on each line are: • source image name (or null string indicating the line for the composite image) • Column number of upper left corner of the image • Row number of upper left corner of the image • width of the image (columns) • height of the image (rows) This option was new in Netpbm 10.6 (July 2002)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Tells pnmmontage to write a C header file of the locations of the original images within the packed image. Each original image generates four #defines within the packed file: xxxX, xxxY, xxxSZX, and xxxSZY, where xxx is the name of the file, con‐ verted to all uppercase. The output also includes #defines OVERALLX and OVERALLY, which specifies the total size of the montage image. Here is an example: #define OVERALLX 227 #define OVERALLY 298 #define X 0 #define Y 0 #define SZX 227 #define SZY 149 #define X 0 #define Y 149 #define SZX 227 #define SZY 149"
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Tells pnmmontage to use the specified prefix on all of the #defines it generates."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Before attempting to place the subimages, pnmmontage will calculate a minimum possible area for the montage; this is either the total of the areas of all the subimages, or the width of the widest subimage times the height of the tallest subimage, whichever is greater. pnmmontage then initiates a problem-space search to find the best pack‐ ing; if it finds a solution that is (at least) as good as the minimum area times the quality as a percent, it will break out of the search. Thus, -quality=100 will find the best possible solution; however, it may take a very long time to do so. The de‐ fault is -quality=200."
        },
        {
            "flag": "-9",
            "long": null,
            "arg": null,
            "description": "These options control the quality at a higher level than -quality; -0 is the worst quality (pick the first solution found), while -9 is the best quality (perform an ex‐ haustive search of problem space for the absolute best packing). The higher the num‐ ber, the slower the computation. The default is -5."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "pamcat",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pamcat/1/json"
        },
        {
            "name": "pnmindex",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmindex/1/json"
        },
        {
            "name": "pnm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/1/json"
        },
        {
            "name": "pam",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pam/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"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Create a montage from multiple PNM images.",
        "examples": [
            {
                "description": "Produce a packing of the specified images",
                "command": "pnmmontage {{path/to/image1.pnm path/to/image2.pnm ...}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Specify the quality of the packing (Note: Larger values produce smaller packings but take longer to compute.)",
                "command": "pnmmontage -{{0..9}} {{path/to/image1.pnm path/to/image2.pnm ...}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Produce a packing that is not larger than `p` percent of the optimal packing",
                "command": "pnmmontage {{-qua|-quality}} {{p}} {{path/to/image1.pnm path/to/image2.pnm ...}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Write the positions of the input files within the packed image to a machine-readable file",
                "command": "pnmmontage {{-d|-data}} {{path/to/datafile}} {{path/to/image1.pnm path/to/image2.pnm ...}} > {{path/to/output.pnm}}"
            }
        ]
    }
}