XB-BOX - 🖼️ 批量图像
Merge loose images into one batch tensor, mute-proof
- 图片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-
Nonetensors, and bakes them into one batch. - If every input is disconnected/muted, it returns
Noneinstead 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.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| 图片1opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 图像 | IMAGE | — |