Image Grid Merger
Turn a batch of images into a contact sheet without leaving the graph
- image_1
- image_2
- image_3
- image_4
- image_5
- image_6
- image
Every serious ComfyUI user eventually wants the same thing: one image that shows six others at a glance. A seed comparison, a before/after upscale, a character turnaround you're eyeballing before committing a whole workflow - you want the whole batch on a single canvas so you can actually see it. Core ComfyUI has no one-click button for that. You'd normally hack it together with ImageBatch, VAE decodes, and manual tensor math, or pull in a kitchen-sink pack for one utility. ImageGridMerger exists because that's annoying. It takes up to six image inputs and lays them out into a tidy grid, fully inside the graph, with no extra dependencies and no models to download.
How it actually works
Under the hood an IMAGE in ComfyUI is a tensor shaped (N, H, W, C) - a batch of frames, even when it's just one image. The node exploits that. Each of its slots (image_1 through image_6) is a batch, and the merger flattens every frame in every connected slot into one pile, then arranges them left-to-right, top-to-bottom. That's the trick that makes this node more flexible than it looks: you're not limited to six images. Wire a sampler or a video's frame sequence into image_1 and a batch of 24 frames becomes a 24-image grid from a single connection.
The layout logic is simple and predictable:
- columns (default 3, 1–10) - how many cells per row. Set it higher than your image count and it just makes one row.
- spacing (default 10, 0–100) - the pixel gutter between cells, both horizontally and vertically.
- background (
white,black,gray) - fills the gaps between cells, any empty cell when your count isn't a multiple ofcolumns, and the padding around images that aren't the biggest.
One behavior the README gets wrong, so the source wins: it says images "are resized to match the largest image in the batch." They are not. Each image is centered on a background-colored canvas the size of the largest width and height - letterboxed and pillarboxed, never stretched. A recent commit is literally titled "Stop stretching images to fill grid cells," so this is deliberate. Mixed aspect ratios give you bars, not distortion, which is usually the nicer result for a contact sheet. Just don't expect every cell to be filled edge-to-edge.
The inputs that matter
You'll touch three things and leave the rest alone:
- image_1 - required, and usually enough. Plug a
LoadImagein, or better, a batch from upstream. - columns - the one you'll fiddle with most; start at 3 and go from there.
- background - set it to match whatever you're pasting the sheet onto.
grayis a decent neutral.
The output is a single image (IMAGE) - the merged grid, one tensor. Wire it into PreviewImage to look, or SaveImage to keep.
Installing it
It's a standard custom node with no install script to speak of:
cd ComfyUI/custom_nodes
git clone https://github.com/SheikhAnas999/Images_Merge_ComfyUI.git
Then restart ComfyUI. Or open ComfyUI Manager → Install Custom Nodes and search "Image Grid Merger" - the pack is registered with the Comfy Registry, so it'll show up. Either way, requirements.txt is a comment saying torch already ships with ComfyUI, so there's nothing to pip install and no model files to fetch. This is one of the rare packs where install genuinely takes one minute.
Where people get burned
- The "resize" surprise. If you wire in mixed-resolution images expecting stretched fills, you'll get centered images with background bars. Not a bug - that's the current design.
- Expecting 6 slots to mean 6 images. Each slot is a batch. Feed 10 frames into
image_1and you get a 10-image grid. The slots are a convenience, not a cap. - Missing from Manager's search. It's published under the display name "Image Grid Merger" - if you're searching by the repo name
Images_Merge_ComfyUIin the wrong place, try the title.
For the job it does, there's not much to go wrong. It's pure tensor ops, no GPU surprises, and it saves you a trip to ImageMagick every time you want to see your outputs side by side.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image_1 | IMAGE | — | |
| columns | INT | 31–10 | — |
| spacing | INT | 100–100 | — |
| background | COMBO | 3 options: white, black, gray | |
| image_2opt | IMAGE | — | |
| image_3opt | IMAGE | — | |
| image_4opt | IMAGE | — | |
| image_5opt | IMAGE | — | |
| image_6opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |