Nodes/ComfyUI-QG-tools/宫格图像拼接
ComfyUI Node

宫格图像拼接

Grid assembly that skips the black frames

By live1617·Created 9 days ago·Updated a day ago· 1
宫格图像拼接
  • images
  • IMAGE
◄match_sizetrue►
◄drop_blacktrue►
◄gap0►
◄background黑色►

Batch size 6, one seed, and now you have six candidates to judge. Flipping through them one at a time is slow and you lose your reference, which is why contact-sheet nodes exist: tile the batch into a single image, look at all six at once, then pick. 宫格图像拼接 (QG_ImageGrid) does the tiling, previews the result right on the node, and has one input switch that makes it noticeably less annoying than the alternatives.

How it works

Feed it a batch tensor or a list of tensors; it takes up to 16 images and lays them out in a near-square grid. The column count is computed, not fixed: one image is 1×1, two become 2×1, three or four become 2×2, five to nine use three columns, and ten to sixteen use four. You don't pick the layout - it picks the layout that wastes the least space, which is the correct default for a contact sheet.

match_size (on by default) unifies every cell to the first image's dimensions, letterboxed and never cropped. That's the right call for a batch out of a sampler, where every frame is already identical in size. Turn it off and each cell keeps its own dimensions, with the row heights and column widths adapting - useful when you're assembling deliberately different images, and a good way to get a lopsided, unreadable sheet if you're not paying attention.

drop_black is the switch this node earns its place with. In a lot of batch workflows, upstream nodes pad unused inputs with black placeholder frames, so a "batch of 4" arrives as 4 images where 2 are pure black. Left alone, your contact sheet is half voids. With drop_black on (default) fully black frames are discarded before tiling. The tradeoff is obvious once stated: a legitimately all-black frame gets dropped too. If your generation actually produces black frames you care about, turn it off.

gap inserts pixels between cells, background picks black or white for the gaps and any leftover space. White background with a small gap is the classic presentation look; black is better when the images are dark and you don't want the grid to glow.

Output is IMAGE - a single composite. The node is also an output-ish node, so the assembled grid renders in its own panel, which is the fastest "which of these six is worth keeping" check you can get inside ComfyUI.

Inputs and outputs

  • images (required, IMAGE) - batch tensor or list; the first 16 are used.
  • match_size (required, boolean, default on) - unify cells to the first image's size, centred, no cropping.
  • drop_black (required, boolean, default on) - discard fully black frames before tiling.
  • gap (required, INT, 0–1000, default 0) - pixel gap between cells.
  • background (required, enum: 黑色 / 白色) - gap and letterbox fill.
  • Output IMAGE - the assembled grid.

Wire the output into a SaveImage for a permanent contact sheet, or into the next stage if you're doing something with the sheet itself - the KB's post-processing notes cover cases where a grid isn't just for looking at, e.g. sprite and tileset work, where the layout is the deliverable.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/live1617/ComfyUI-QG-tools

Restart ComfyUI fully - console confirms [QG-tools] v0.9.2 加载完成 | 节点数 24. Manager search for ComfyUI-QG-Tools works where the Registry listing exists. Zero pip dependencies: the pack's requirements file is comments-only so Manager skips the pip step entirely, and this node only needs torch and PIL, both of which ComfyUI already ships.

Ported from ComfyUI_Muye (MIT) and searchable as grid, contact sheet, tile or 宫格.

Where people get burned

Black frames disappearing when you wanted them. Covered above, but it's the number one surprise. drop_black is on by default and it means exactly what it says - and if every frame gets dropped, the node raises rather than handing you an empty grid.

16 is a hard cap. Feed a batch of 32 and you get the first 16. If you need more, split the batch and tile twice, or accept two sheets. Silently dropping frames is wrong for a preview node and it's still what the node does, so check your batch size first.

Mixed sizes without match_size. With it off, cells keep original dimensions and rows can end up ragged; a 1024-wide image next to a 512-wide one makes a lopsided sheet. If the result looks broken rather than artistic, that switch is why.

Assuming the grid is your final output resolution. It isn't - it's whatever the cells add up to, gaps included. If you're feeding it into a model instead of a save node, run the dimensions through 图像或 Latent 尺寸 first and check they're something a VAE will accept.

CategoryQG-tools/Image

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE接批次张量或张量列表;最多取前 16 张
match_sizeBOOLEANtrue开:所有格子统一成第一张的尺寸(图在格内等比居中,不裁剪);关:各图保持原尺寸
drop_blackBOOLEANtrue开:丢掉全黑帧(上游批次节点常给未接输入补黑图占位);关:全黑帧也照常拼进去
gapINT00–1000格子之间的像素间隙
backgroundCOMBO黑色间隙与留白填充的颜色

Outputs (1)

NameTypeDescription
IMAGEIMAGE拼好的宫格图。