ScarlotSoft Image/Mask From Batch
Slice frames out of a batch — ScarlotSoft Image/Mask From Batch
- images
- masks
- IMAGE
- MASK
Once you start running batches, you'll hit the moment where you need one image out of a stack. Your KSampler spat out a batch of four, your video node produced thirty frames, or your mask batch and image batch got out of alignment - and you need frame 3, or frames 2–4, as its own thing. ScarlotSoft From Batch is the slice: start_index and num_frames in, and it carves that window out of whatever batch you feed it.
The inputs are about as minimal as they come: start_index (default 0), num_frames (default 1), and the two optional sockets, images and masks. Both are optional, so you can slice images alone, masks alone, or both at once. Outputs are IMAGE and MASK - if you only connected one side, the other output comes back None, which ComfyUI tolerates if the downstream node doesn't need it. When both are connected, they're sliced with the same indices, which is the feature that saves you a headache: grab image and mask together and they stay aligned, so you can pull "frame 3 plus its mask" in one go.
The mechanism is a plain tensor slice - images[start:start+num] - plus a safety net. If your indices run past the end of the batch, it doesn't crash; it logs a warning and hands back the last frame instead. That's a small mercy when you're scripting runs blind, though it does mean an out-of-range slice silently gives you something instead of telling you you asked wrong. If you're looping and the batch size changes between runs, keep an eye on the console for that warning - it's your only signal.
Typical places this shows up: pulling a single frame out of a video-adjacent batch for a detail pass, extracting one image from a multi-seed batch to inspect it, or splitting a latently-generated batch so different frames take different post-processing paths. It's also the natural complement to the suite's batch-producing nodes. Since it's pure tensor indexing, it's effectively free at runtime.
Install with the pack - ComfyUI Manager → search ScarlotSoft → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/scarlotsoft/ComfyUI_ScarlotSoft
No dependencies, nothing to download. Suite theme, hard-refresh after a UI-mode switch.
Worth being clear-eyed: the core ComfyUI ImageFromBatch and MaskFromBatch nodes do this same slicing, and if you're not in this pack you don't need this node - the pair of core nodes is the standard tool. What this adds is the combined one-node interface (image and mask sliced together with shared indices) and the graceful fallback. If you've ever fought to keep a mask batch aligned with its image batch using two separate from-batch nodes, you'll appreciate the joint version immediately. For beginners it's also just easier to find than the core pair.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| start_index | INT | 00–99999 | — |
| num_frames | INT | 11–99999 | — |
| imagesopt | IMAGE | — | |
| masksopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |