Get Images From Batch Indexed (Swwan)
Pick frames by number, in any order
- images
- IMAGE
The other half of batch slicing
Get Image Range From Batch gives you a start and a count - contiguous, ordered, one window. This node gives you a list: 0, 7, 12 and you get those three frames in that exact order. That's a different job, and it's the one you need more often than you'd expect: pulling keyframes for a contact sheet, grabbing the first and last frame of a clip to hand a model an image pair, reordering a batch into a specific sequence, or duplicating a frame to hold on it.
KJNodes' GetImagesFromBatchIndexed, re-registered by the Swwan pack.
How it works
indexes is parsed by splitting the string on commas and converting each piece to an integer, then used as a fancy-index into the image tensor - images[indices_tensor]. That one line tells you most of the behaviour:
- Order is yours.
7, 0, 3gives you frame 7 first. - Duplicates are allowed.
0, 0, 0, 4gives you three copies of frame 0 then frame 4. Cheap way to hold a frame. - Negative indices work, because PyTorch allows them:
-1is the last frame. Convenient, and easy to misread later when you've forgotten. - Out-of-range indices error out with a torch index error, not a friendly message. There's no clamping.
Inputs and outputs
images- requiredIMAGEbatch.indexes- requiredSTRING, default0, 1, 2, multiline. Spaces are stripped, so0, 1, 2and0,1,2are the same. What isn't handled: anything that isn't an integer. A trailing comma (0, 1, 2,) produces an empty element and aValueError; a range like0-3isn't a range, it's a crash; and1, 2.0is a float-conversion error. If you're generating this string programmatically, generate it clean.
Output: a single IMAGE. The output batch is exactly as long as the number of indices, and every frame keeps its original resolution - this node does not resize anything. Since a ComfyUI batch must be uniformly shaped, you can't mix frames from different-sized batches here; that's what the pack's image list nodes are for.
The index string is also a widget you can convert to an input and drive from elsewhere - a string primitive, a text file, whatever. That's the interesting wiring: an external frame list becomes your edit decision list.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/aining2022/ComfyUI_Swwan
cd ComfyUI_Swwan
python -m pip install -r requirements.txt
Manager → ComfyUI Swwan, restart, hard-refresh. Pure indexing, no models, no optional dependencies.
When to reach for it
Three cases where this beats wiring three separate range nodes: prompt/batch alignment - many workflows attach captions or conditioning per batch index, and reordering images without reordering the conditioning silently desyncs everything; a single indexing node makes the permutation visible in one place. Image pairs - first and last frame out of a clip is 0, -1, and that's an entire node saved. Presets from a long batch - pick frames 0, 24, 48, 72 out of a 96-frame render and you have a storyboard without a preview node in sight.
The failure mode to expect is a batch that quietly isn't the length you assumed. If the batch upstream was a single image (a batch of one) and you ask for 0, 1, 2, you get an index error - and on a video-extension workflow, where "images" might be a context window whose length the model chose, that's common enough that it's worth checking with Get Image Size & Count first and reading the count output when something explodes.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| indexes | STRING | 0, 1, 2 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |