Nodes/yanhuo-easy-use/图像批次合并
ComfyUI Node

图像批次合并

The batch merger that won't crash on mismatched sizes

By yanhuoxunxianren·Created 27 days ago·Updated 21 days ago· 2
图像批次合并
  • image_1
  • image_2
  • image_3
  • image_4
  • image_5
  • image_6
  • image_7
  • image_8
  • image_9
  • image_10
  • image_11
  • image_12
  • image_13
  • image_14
  • image_15
  • image_16
  • image_17
  • image_18
  • image_19
  • image_20
  • image_21
  • image_22
  • image_23
  • image_24
  • image_25
  • image_26
  • image_27
  • image_28
  • image_29
  • image_30
  • image_31
  • image_32
  • image_33
  • image_34
  • image_35
  • image_36
  • image_37
  • image_38
  • image_39
  • image_40
  • image_41
  • image_42
  • image_43
  • image_44
  • image_45
  • image_46
  • image_47
  • image_48
  • image_49
  • image_50
  • images
◄输入数量3►
◄尺寸处理缩放到第一张►
◄跳过黑色占位图true►

Combining images from different branches into one batch is one of those operations ComfyUI makes you fight for. The stock image-batch nodes are picky: sizes must match, empty inputs sometimes sneak in as black frames, and the failure mode is an exception mid-run. This node is the version that assumes your graph is messy and deals with it.

What it's for

Three real situations. You generated a batch in one branch and a single extra frame in another and want them sampled together. You're assembling a grid or a contact sheet from sources that were never the same resolution. Or you want to concatenate several batches into one queue item so a save node writes them all with one prefix and an incrementing counter.

Reach for it when the sizes are wrong and you don't want to add resize nodes in front of every input just to satisfy a merger.

The inputs, in the order that matters

输入数量 (2–50) sets how many image_1…image_50 ports exist. Change it and then click 更新输入 on the node - the sockets won't appear until you commit the number. Everyone hits this once.

尺寸处理 is the heart of it, six options:

  • 缩放到第一张 - default, and the one you want most of the time. Everything is stretched (bilinear) to the size of the first valid input. Which means port order decides your output resolution: put the batch you care about on image_1.
  • 缩放到最大 - everything stretches to the largest width/height across all inputs. Non-uniform, so aspect ratios get squashed. Fine for quick contact sheets, ugly for anything else.
  • 中心缩放裁切到最大 - scale by the max factor until it covers the target, then centre-crop. No distortion, no letterboxing, but it eats the edges. Use when the frame edges don't matter.
  • 填充到最大 - preserve aspect, centre, pad with black to the largest size. No distortion, black bars.
  • 按原像素(图像列表) - no resizing at all. Output becomes a genuine list of images at their original, possibly differing, resolutions. Only works downstream where each element is handled separately.
  • 严格 - sizes must match exactly or the run errors out. The old behaviour, available by choice.

跳过黑色占位图 (default on) is the other important switch. Nodes in this ecosystem - including this pack's own 筛选图像 - output a 64×64 all-black frame when they have no result, so that empty branches don't break a chain. This toggle recognizes that specific stub (1×64×64, all values at or below float rounding noise) and treats it as an empty input. If you're merging outputs from a filter that found nothing, leave it on. If you're legitimately merging 64×64 black frames - you monster - turn it off.

Then there's the skip logic you don't configure: unconnected ports, non-tensor inputs, and batches with zero images are all passed over silently, and the merger continues with the next valid port. Gone is the old behaviour where an empty input inserted a black frame into your batch.

Channel count is resolved by the first input as well: extra channels get cut, missing ones are filled with 1.0. And if literally every port is empty, you get one 64×64 black frame rather than a stack trace - the same convention, used so the graph doesn't hard-fail.

The output

One port, images, typed IMAGE and marked as a list. In the normal modes the list holds a single merged batch, which downstream nodes treat like any other IMAGE batch - negligible difference. In 按原像素(图像列表) mode the list holds one element per image, each at its own size, which is the mode people misunderstand: a node that expects a uniform batch will not be happy.

Install

Part of yanhuo-easy-use - 16 utility nodes, category yanhuo, Chinese labels, MIT. ComfyUI Manager → search the pack title. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanhuoxunxianren/yanhuo-easy-use
# restart ComfyUI

No pip install: pyproject.toml lists no dependencies and the pack uses only what ComfyUI ships (torch, numpy, Pillow, comfy.utils). Nothing to download.

Common issues

"My output is the wrong size." You're on 缩放到第一张 and the first port isn't the image you meant. Reorder the wiring, or switch to 按原像素.

"The aspect ratio looks stretched." Default stretch-to-first is a straight bilinear resize - it deforms. Use 中心缩放裁切到最大 or 填充到最大 when proportions matter, and read the tooltip before picking; the author documents the tradeoff per mode.

"A black 64×64 image ended up in the batch." Either 跳过黑色占位图 is off, or the placeholder came from something that isn't exactly 1×64×64 black (a cropped or resized stub won't match the detector).

"Downstream says the batch is inconsistent." Only possible in 按原像素 mode, where each element keeps its own resolution by design.

"Merged images look soft." You merged 512px images into a 1024px target, or vice versa - the resize is real resampling, not a container change. Match sizes upstream if quality matters; this node is a convenience, not a resampler you'd choose deliberately. The native-resolution table in docs/knowledge/troubleshooting.md is worth keeping in mind so you don't hand a model a size it never trained on.

Categoryyanhuo

Inputs (53)

NameTypeDefaultDescription
输入数量INT32–50—
尺寸处理COMBO缩放到第一张各路分辨率不一致时的处理方式: ● 缩放到第一张(默认):全部拉伸到第 1 路有效输入的尺寸,自动对齐、不报错。 ● 缩放到最大:全部拉伸到所有输入中最大的宽高(不等比,画面会变形)。 ● 中心缩放裁切到最大:等比缩放到覆盖最大宽高后居中裁切,不拉伸变形、无黑边(会裁掉边缘)。 ● 填充到最大:保持各自比例居中放置,四周补黑到最大宽高(不变形、有黑边)。 ● 按原像素(图像列表):完全不缩放,输出为图像列表,列表中每张图保持原始分辨率(可各不相同)。 ● 严格:尺寸必须完全一致,否则报错中断。
跳过黑色占位图BOOLEANtrue上游筛选类节点在无结果时会输出 1 张 64×64 全黑兜底图。开启时把这类输入视为空输入并跳过,不参与合并。
image_1optIMAGE—
image_2optIMAGE—
image_3optIMAGE—
image_4optIMAGE—
image_5optIMAGE—
image_6optIMAGE—
image_7optIMAGE—
image_8optIMAGE—
image_9optIMAGE—
image_10optIMAGE—
image_11optIMAGE—
image_12optIMAGE—
image_13optIMAGE—
image_14optIMAGE—
image_15optIMAGE—
image_16optIMAGE—
image_17optIMAGE—
image_18optIMAGE—
image_19optIMAGE—
image_20optIMAGE—
image_21optIMAGE—
image_22optIMAGE—
image_23optIMAGE—
image_24optIMAGE—
image_25optIMAGE—
image_26optIMAGE—
image_27optIMAGE—
image_28optIMAGE—
image_29optIMAGE—
image_30optIMAGE—
image_31optIMAGE—
image_32optIMAGE—
image_33optIMAGE—
image_34optIMAGE—
image_35optIMAGE—
image_36optIMAGE—
image_37optIMAGE—
image_38optIMAGE—
image_39optIMAGE—
image_40optIMAGE—
image_41optIMAGE—
image_42optIMAGE—
image_43optIMAGE—
image_44optIMAGE—
image_45optIMAGE—
image_46optIMAGE—
image_47optIMAGE—
image_48optIMAGE—
image_49optIMAGE—
image_50optIMAGE—

Outputs (1)

NameTypeDescription
imagesIMAGE—