{
    "mode": "man",
    "parameter": "pnmmontage",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pnmmontage/1/json",
    "generated": "2026-07-05T01:48:53Z",
    "synopsis": "pnmmontage  [-?|-help]  [-header=headerfile]  [-quality=n] [-prefix=prefix] [-0|-1|-2|...|-9]\npnmfile...",
    "sections": {
        "NAME": {
            "content": "pnmmontage - create a montage of portable anymaps\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pnmmontage  [-?|-help]  [-header=headerfile]  [-quality=n] [-prefix=prefix] [-0|-1|-2|...|-9]\npnmfile...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Packs images of differing sizes into a minimum-area composite image, optionally producing a C\nheader file with the locations of the subimages within the composite image.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-?, -help",
                    "content": "Displays a (very) short usage message.\n",
                    "flag": "-?"
                },
                {
                    "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 #defines OVERALLX and OVERALLY are also produced, speci‐\nfying the total size of the montage image.\n"
                },
                {
                    "name": "-prefix",
                    "content": "Tells pnmmontage to use the specified prefix on all of the #defines it generates.\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, -q  100  will  find  the\nbest  possible  solution; however, it may take a very long time to do so.  The default\nis -q 200.\n"
                },
                {
                    "name": "-0, -1, ... -9",
                    "content": "These options control the quality at a higher level than -q; -0 is the  worst  quality\n(literally  pick  the  first solution found), while -9 is the best quality (perform an\nexhaustive search of problem space for the absolute best  packing).   The  higher  the\nnumber, the slower the computation.  The default is -5.\n",
                    "flag": "-9"
                }
            ]
        },
        "NOTES": {
            "content": "Using  -9  is  excessively slow on all but the smallest image sets.  If the anymaps differ in\nmaxvals, then pnmmontage will pick the smallest maxval which is evenly divisible by  each  of\nthe maxvals of the original images.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pnmcat(1), pnmindex(1), pnm(5), pam(5), pbm(5), pgm(5), ppm(5)\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright (C) 2000 by Ben Olmstead.\n\n\n\n31 December 2000                             pnmmontage(1)",
            "subsections": []
        }
    },
    "summary": "pnmmontage - create a montage of portable anymaps",
    "flags": [
        {
            "flag": "-?",
            "long": null,
            "arg": null,
            "description": "Displays a (very) short usage message."
        },
        {
            "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 #defines OVERALLX and OVERALLY are also produced, speci‐ fying the total size of the montage image."
        },
        {
            "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, -q 100 will find the best possible solution; however, it may take a very long time to do so. The default is -q 200."
        },
        {
            "flag": "-9",
            "long": null,
            "arg": null,
            "description": "These options control the quality at a higher level than -q; -0 is the worst quality (literally pick the first solution found), while -9 is the best quality (perform an exhaustive search of problem space for the absolute best packing). The higher the number, the slower the computation. The default is -5."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "pnmcat",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmcat/1/json"
        },
        {
            "name": "pnmindex",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmindex/1/json"
        },
        {
            "name": "pnm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/5/json"
        },
        {
            "name": "pam",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pam/5/json"
        },
        {
            "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"
        }
    ],
    "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}}"
            }
        ]
    }
}