Batch Images One or More
ComfyUI's ImageBatch, but it doesn't need exactly two
- image1
- image2
- image3
- image4
- image5
- image6
- IMAGE
Stock ComfyUI ImageBatch takes exactly two images and stacks them into one batch tensor. That's fine until your workflow sometimes has one image and sometimes has five - then you're either chaining multiple ImageBatch nodes together or rewiring the graph depending on how many inputs you have this run. This node collapses that into one: up to six image slots, and only the first is actually required.
What it's solving
The real annoyance with the stock node isn't the limit of two, it's that both inputs are required - leave one unconnected and you get an error before the graph even runs, regardless of whether you actually wanted a batch of one. ImageBatchOneOrMore only requires image1; image2 through image6 are all optional. That means the same node handles "just pass this one image through" and "stack these five together" without you needing to detect which case you're in and swap nodes.
Inputs and outputs
image1- required.image2throughimage6- optional, added into the batch if connected, skipped if not.
Output: a single IMAGE, batched along the standard batch dimension - same as stock ImageBatch, just with more slots and a lower bar to use it with fewer than two.
Same rule as stock ImageBatch still applies here: batching stacks tensors together, so the images you connect need to share the same height and width. This node expands how many you can combine, not the size-matching requirement itself - if you need to combine mismatched sizes, that's what ImageConcanateOfUtils (with its built-in upscale-to-match) is for instead, since concatenation and batching are different operations with different constraints.
Where this genuinely earns its keep over chaining several stock ImageBatch nodes: a workflow with a variable number of reference images per run - sometimes one, sometimes four - where you'd otherwise need conditional logic just to decide how many ImageBatch nodes to wire together. Here it's the same node every time regardless of how many of the six slots actually have something plugged in.
Installing it
ComfyUI Manager: search "ComfyUI-utils-nodes." Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes
Restart ComfyUI. No dependencies, no model downloads - it's tensor stacking.
The main thing to watch for
If you get a shape-mismatch error the moment you connect a fourth or fifth image, the almost-certain cause is a size mismatch, not a bug in the node - check that every image you're feeding it is actually the same resolution before assuming something's wrong with the batching logic itself. And remember it's additive in connection order: if you skip image2 and only wire image1 and image3, you'll still get a batch of two, just built from those two slots - there's no gap left behind for the one you didn't connect.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |