Select Indexes From Images
Frame selection, without the 'range' headaches
- images
- images
You loaded a 300-frame clip and you need frames 10–20, or every 4th frame, or just the last one. Most ComfyUI frame handling makes you either take everything or write tedious per-index nodes. Select Indexes From Images gives you a single text field with one compact syntax that does all of it. It's the frame-filtering workhorse of SineSwiper's LoadAnim-Adv pack, and once you've used it, the stock way feels broken.
The one input that matters: the syntax
Everything about this node is the indexes_to_select string. It's Python's range() written with colons - first frame is index 0, negative numbers count from the end:
5- frame 5 only0:5- frames 0 through 4 (end exclusive)1:- frame 1 to the end:-5- everything except the last 5 frames::2- every second frame0:10:2- frames 0, 2, 4, 6, 8-1- the last frame0,5:10,-1- mix singles, ranges, and the tail, separated by commas
Empty :: on its own is a full slice, and the default value is 0: - which is "everything from frame 0 on," i.e., pass-through. If you're coming from Python's range, this is that, with negatives working the way you'd hope.
How it works
The node takes an IMAGE tensor - which in ComfyUI is laid out as [frames, height, width, channels] - and indexes along the frame axis. Feed it a still image and it's a one-element tensor, so any valid selection is a no-op unless you pick 0. Feed it a multi-frame tensor from a loader in this pack (or any animated source) and you get back a new tensor holding only the selected frames, same order as written. Empty or invalid selections raise an error rather than silently returning nothing.
When to reach for it
- After a directory loader, to trim each file down to the frames that matter.
- Before a video-model pipeline that wants a specific frame count or a stride -
::2is an easy way to halve a clip for faster sampling. - For extracting a single keyframe (
-1for the last frame of a render) to feed a refiner or an upscaler.
Inputs and outputs
Just two inputs: images (an IMAGE tensor) and indexes_to_select (the string). One output: images, the selected set. That's the whole node - refreshingly small, which is exactly right for a node whose only job is slicing.
Installing
Part of ComfyUI-LoadAnim-Adv by SineSwiper. ComfyUI Manager → search "LoadAnim", or:
cd ComfyUI/custom_nodes
git clone https://github.com/SineSwiper/ComfyUI-LoadAnim-Adv.git
Restart ComfyUI. No models, no extra dependencies beyond what a stock install already has (torch, numpy, Pillow).
Gotchas
- End-exclusive ranges catch everyone.
0:10gives you 10 frames (0–9), not 11. If you want frames 1 through 10 inclusive, write1:11. - Negative selection is "from the end," not "from the start going down" -
-1is the last frame, and you can't select a frame "at index -2 in the front." - This node expects a single tensor. If your upstream sends a list of tensors (the directory loader with
flatten_framesoff), it handles that too - it runs the selection on each set - but for a flat single tensor, this is all you need.
One text field, one syntax, and suddenly frame cherry-picking isn't a chore. Learn the syntax once and it carries across the whole pack - the directory loader and Select Indexes From Any speak the same language.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | Image set to select from. | |
| indexes_to_select | STRING | 0: | Indexes (zero-based) to select. Supports ':' for range selection (including ':#', '#:' formats), '::#' & '#::#' & '#:#:#' formats for step selection, ',' for multiple entries, and negative numbers for selecting from the end. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | The selected image set. |