ImageToBatch
Splice One Image Into a Batch Without Breaking the Graph
- image_batch
- image
- image
ComfyUI is quietly full of nodes that take a whole batch and a few that let you put one thing into a batch. ImageToBatch is one of the few: it replaces or inserts an image (or a small batch) into an existing image batch at a chosen index. It's a plumbing node - nobody builds a workflow around it, but when you need it, you really need it.
The classic scenario: you've got a batch of generated images heading into a ControlNet, an upscaler, or a comparison grid, and you want to swap one frame, inject a reference image at slot zero, or append a new sample. Without this, your options are hacky concat-then-slice games. With it, you set an index and pick a mode: replace overwrites an existing slot (batch size stays the same), insert shifts everything to the right and grows the batch. The replace-by-default change landed in version 1.2.52 - before that it always inserted, which caught people off guard, so check which mode you're in.
How it works
Under the hood it's a tensor splice along the batch dimension. The incoming image can itself be a batch of several images, and the node places all of them starting at index. The constraints are the honest ones: spatial shape, channel count, dtype, and device must all match the target batch, because there's no resizing or conversion happening here - it's placement, not adaptation.
The inputs that matter
image_batch- the batch you're modifying.image- what you're placing (single image or small batch).index- where it goes. Inreplacemode it must point at an existing item; ininsertmode it can equal the current batch size to append.mode-replace(overwrite, same size) orinsert(shift right, grows).
Output is the modified IMAGE batch.
Installing it
Part of Skoogeer-Noise. Manager → search "Skoogeer-Noise", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/Skoogeer-Noise
Restart ComfyUI. Deps are torch, numpy>=1.26, einops, pyyaml>=6.0.3; no model downloads.
Common gotchas
The error you'll actually hit is a shape mismatch: drop a 1024×1024 image into a batch of 512×512s and it fails loudly, because the node won't resize for you. Resize upstream. Also mind the index semantics between modes - replace at an index past the end errors, while insert at batch_size is a valid append. And if a workflow you downloaded predates 1.2.52, its ImageToBatch may rely on the old always-insert behavior; re-check the mode dropdown if the batch size isn't what you expect.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image_batch | IMAGE | Existing image batch to modify. | |
| image | IMAGE | Image or image batch to place at the requested index. | |
| index | INT | 00–4096 | Batch index where the image is placed. |
| mode | COMBO | replace | replace overwrites existing item(s); insert shifts existing items right. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |