Nodes/XB_ToolBox/XB-BOX - ๐Ÿ–ผ๏ธ ๆ‰น้‡ๅ›พๅƒ
ComfyUI Node

XB-BOX - ๐Ÿ–ผ๏ธ ๆ‰น้‡ๅ›พๅƒ

Merge loose images into one batch tensor, mute-proof

By wjluoxiaoยทCreated 7 months agoยทUpdated a day agoยท 406
XB-BOX - ๐Ÿ–ผ๏ธ ๆ‰น้‡ๅ›พๅƒ
  • ๅ›พ็‰‡1
  • ๅ›พๅƒ

A batch tensor is how ComfyUI runs a sampler across several images at once - but getting your images into one tensor usually means the rigid built-in BatchImages node, which demands every input be connected. XB_BatchImages is the flexible re-implementation: all inputs optional, muted or empty slots silently skipped, and the remaining images merged into a single IMAGE batch. Wire five images, mute two of them with a switch, and you get a three-image batch - no error, no rewiring.

It lives in XB_ToolBox/Utils, and it's the kind of small node that quietly unblocks batch workflows. Batch img2img, batch face-swap, feeding several reference frames to a video encoder - anywhere multiple images need to become one tensor, this is the glue.

How it works

Mechanically it clones the official node's behavior (the file header says so explicitly): each input image is channel-padded to the max channel count, resized to match the first image's dimensions (bilinear, center), and concatenated into one tensor. The difference is the input handling:

  • Inputs are declared via a flexible optional-input pattern, so you get a stack of ๅ›พ็‰‡1, ๅ›พ็‰‡2, โ€ฆ sockets (up to 50) and every one can be left disconnected.
  • At runtime it iterates its inputs, keeps only non-None tensors, and bakes them into one batch.
  • If every input is disconnected/muted, it returns None instead of crashing - which downstream optional inputs read as "not connected."

That last bit is the real win: it lets a conditional/mute switch control how many images are in the batch at runtime, so the same workflow can process 1 or 5 images depending on what's live. That's the "skip muted" behavior people fight ComfyUI's stock node to get.

The inputs that matter

  • ๅ›พ็‰‡1โ€ฆๅ›พ็‰‡N - optional IMAGE inputs (Chinese labels, matching the pack's UI language). Connect as many or as few as you need; up to 50.

Output: ๅ›พๅƒ - the merged IMAGE batch. Wire it into a sampler, a batch-capable upscaler, or a video-encode path that takes a batch.

Installing

Part of XB_ToolBox - ComfyUI Manager โ†’ search XB_ToolBox, or

cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git

restart, zero extra dependencies. It uses the pack's flexible-input machinery, so make sure the frontend refreshed after install.

Common issues

  • "At least 1 image" error - every input is actually disconnected. Wire at least one.
  • Images get resized unexpectedly - batching forces a common size (it matches the first connected image). If your images are different resolutions, the node upscales to the first one's size. Normalize upstream if you need control over the target size.
  • Names look odd (ๅ›พ็‰‡1) - cosmetic; the pack's UI is Chinese-first. The sockets work like any IMAGE input.

If you mostly run single-image jobs this is unnecessary, but the moment a workflow needs "some images, depending on the run," this one node removes an entire class of "muted input broke my batch" failures.

CategoryXB_ToolBox/Utils

Inputs (1)

NameTypeDefaultDescription
ๅ›พ็‰‡1optIMAGEโ€”

Outputs (1)

NameTypeDescription
ๅ›พๅƒIMAGEโ€”