Smart Grid Stitch
Nine images into one tidy grid, without fighting cell sizes
- image_1
- image_2
- image_3
- image_4
- image_5
- image_6
- image_7
- image_8
- image_9
- grid_image
Grids are the unglamorous backbone of a lot of ComfyUI work: comparison matrices, prompt grids, thumbnail sheets, or reassembling tiles after a split-and-upscale pass. Smart Grid Stitch is the node in the Niutonian Smart Image Suite that turns up to nine IMAGEs into a single grid image, and it handles the part that usually drives people nuts - getting mismatched images to sit in uniform cells without looking like a ransom note.
Like the rest of the pack it's pure Pillow: no models, no API, no downloads. It's the natural partner to Smart Image Splitter - that node cuts a grid out of one image, this one puts one back together.
How it works
Wire image_1 through image_9 (all optional - empty inputs are skipped, the pack's signature behavior). grid_mode decides the layout: auto picks a sensible arrangement based on how many images you connected, or you can force 2x2, 3x3, 4x4, 2x3, 3x2, 1x6, 6x1. fill_direction controls whether images fill row by row or column by column.
Then comes the sizing logic. Every image gets resized to a common cell size determined by cell_sizing - largest (cells as big as the biggest image), smallest, average, or custom with your own custom_width / custom_height. Each image is then forced into its cell via aspect_ratio_handling: pad letterboxes it, crop center-crops to fill the cell exactly, stretch squashes it. pad is the safe default - it preserves content, which is what you want for a comparison grid where nobody's face should be getting stretched.
gap_size puts breathing room between cells, background_color fills the gaps, and empty_cell_style decides what happens when a cell has no image left: skip collapses the grid to only the filled cells, placeholder leaves a blank cell, repeat_last pads with the previous image. skip is great for ragged counts; placeholder keeps positions stable if you're comparing across runs.
Wiring it up
Output is grid_image (IMAGE) - straight into a Save Image or a preview. A genuinely useful pattern: SmartImageSplitter (3x3, overlap ~32) → upscale each tile → this node with grid_mode 3x3, gap_size 0, aspect_ratio_handling crop or stretch to rebuild the full-res image. Because the tiles are all exactly the same size when they come back from a uniform upscale, this is the smoothest reassembly path in the pack.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/Niutonian/comfyui-niutonian-smart-image
Restart and look under Niutonian/Image Processing. No extra dependencies - Pillow, numpy, torch, all already in ComfyUI. No model files anywhere in this pack.
Two things to keep in mind. repeat_last only kicks in when there's already a processed image to copy, so an empty first row still leaves holes. And the whole suite is young - a single initial commit from early 2026 - so for most people the auto mode plus pad plus a small gap is the combination that "just works," and the fancier combinations are where you'll be the beta tester.
Inputs (19)
| Name | Type | Default | Description |
|---|---|---|---|
| grid_mode | COMBO | auto | 8 options: auto, 2x2, 3x3, 4x4, 2x3, 3x2, +2 |
| fill_direction | COMBO | row_first | 2 options: row_first, column_first |
| cell_sizing | COMBO | largest | 4 options: largest, smallest, average, custom |
| aspect_ratio_handling | COMBO | pad | 3 options: pad, crop, stretch |
| resize_method | COMBO | lanczos | 4 options: lanczos, bilinear, bicubic, nearest |
| gap_size | INT | 100–100 | — |
| background_color | COMBO | white | 4 options: transparent, white, black, gray |
| empty_cell_style | COMBO | skip | 3 options: skip, placeholder, repeat_last |
| custom_widthopt | INT | 51264–2048 | — |
| custom_heightopt | INT | 51264–2048 | — |
| image_1opt | IMAGE | — | |
| image_2opt | IMAGE | — | |
| image_3opt | IMAGE | — | |
| image_4opt | IMAGE | — | |
| image_5opt | IMAGE | — | |
| image_6opt | IMAGE | — | |
| image_7opt | IMAGE | — | |
| image_8opt | IMAGE | — | |
| image_9opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| grid_image | IMAGE | — |