ComfyUI Node

Smart Grid Stitch

Nine images into one tidy grid, without fighting cell sizes

By Niutonian·Created 7 months ago·Updated 7 months ago· 0
Smart Grid Stitch
  • image_1
  • image_2
  • image_3
  • image_4
  • image_5
  • image_6
  • image_7
  • image_8
  • image_9
  • grid_image
grid_modeauto
fill_directionrow_first
cell_sizinglargest
aspect_ratio_handlingpad
resize_methodlanczos
gap_size10
background_colorwhite
empty_cell_styleskip
custom_width512
custom_height512

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.

CategoryNiutonian/Image Processing

Inputs (19)

NameTypeDefaultDescription
grid_modeCOMBOauto8 options: auto, 2x2, 3x3, 4x4, 2x3, 3x2, +2
fill_directionCOMBOrow_first2 options: row_first, column_first
cell_sizingCOMBOlargest4 options: largest, smallest, average, custom
aspect_ratio_handlingCOMBOpad3 options: pad, crop, stretch
resize_methodCOMBOlanczos4 options: lanczos, bilinear, bicubic, nearest
gap_sizeINT100–100
background_colorCOMBOwhite4 options: transparent, white, black, gray
empty_cell_styleCOMBOskip3 options: skip, placeholder, repeat_last
custom_widthoptINT51264–2048
custom_heightoptINT51264–2048
image_1optIMAGE
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
image_5optIMAGE
image_6optIMAGE
image_7optIMAGE
image_8optIMAGE
image_9optIMAGE

Outputs (1)

NameTypeDescription
grid_imageIMAGE