Nodes/Claude CLI (Vision+Text)/Select Images (Bounds Safe)
ComfyUI Node

Select Images (Bounds Safe)

VHS SelectImages, minus the crash

By RandyHaylor·Created 4 months ago·Updated 4 months ago· 1
Select Images (Bounds Safe)
  • image
  • image
  • selected_count
  • skipped_count
indexes0
err_if_bad_indexfalse
err_if_emptyfalse
fallback_on_emptyfirst_frame

If you've built a video workflow, you know VideoHelperSuite's SelectImages - it's the standard way to pick frames out of a batch by index. You also may know its one infuriating bug: with err_if_missing=False (the way most people run it), out-of-bounds indices slip past the check and crash the tensor indexing step with a raw IndexError. Select Images (Bounds Safe) is a drop-in replacement that fixes exactly that, and adds nothing you have to learn.

It parses the same VHS-style index syntax - "3", "0,2,5", "2:8", "0:10:2", "-1" for the last frame, or mixed like "0,2:4,-1" - but filters the results against the actual batch size before touching the tensor. Out-of-range indices get silently skipped instead of blowing up your graph. You swap the node, keep your workflow's existing index strings, and the crash stops.

Why you'd reach for it

The classic case is grabbing the last frame of a video: "-1" in a SelectImages node is a real, widely-used trick for "final frame, please." But it only works while the batch has the length you assumed. The moment a video comes back a few frames shorter than expected - different source, a dropped frame - -1 still resolves fine, but a hardcoded "240" turns into a crash. This node turns that crash into a skipped index, and reports exactly what it did via the count outputs. For batch video analysis it's also a nice safety net: build your index list once, let frame counts drift, never re-trip the graph.

Inputs and outputs

  • image - the IMAGE batch to select from.
  • indexes - the string expression, VHS syntax exactly as you're used to.
  • err_if_bad_index (default False) - True means out-of-range indices raise an IndexError naming the offenders; False means they're skipped silently.
  • err_if_empty (default False) - raise if nothing valid survives the filter.
  • fallback_on_empty (default first_frame) - when no valid indices remain: first_frame returns frame 0, all_frames returns the whole batch, blank returns a black frame.

Outputs: image (the selected frames, in the order you listed them), selected_count, and skipped_count - the last two exist precisely so you can see when a "silent skip" is actually eating your data.

Installing it

Same install as the rest of the pack, and again: this node needs no Claude Code, no login, no API key - it's pure tensor slicing. Search ComfyUI Manager for "Claude CLI (Vision+Text)" or clone:

cd <ComfyUI>/custom_nodes
git clone https://github.com/RandyHaylor/comfyui-claude-cli-vision-text-node.git

Restart, hard-refresh the browser tab (Ctrl+Shift+R). No pip install - the pack's only dependencies are numpy, torch, and Pillow, all already in ComfyUI.

The traps

  • With err_if_bad_index=False (the default), a typo in your indexes silently drops frames - no error, just a shorter output. The selected_count / skipped_count outputs are there to catch exactly this; glance at them once if anything looks off.
  • fallback_on_empty defaults to first_frame, so an empty selection quietly hands you frame 0. That can look like a bug when it's actually the intended safety behavior - change it to blank if you'd rather see an obvious black frame than a plausible-but-wrong one.
  • -1 still means "last frame," and negative indices are resolved against the actual batch length, which is what makes the bounds-safe behavior feel so seamless in practice.
Categoryutility

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
indexesSTRING0
err_if_bad_indexBOOLEANfalse
err_if_emptyBOOLEANfalse
fallback_on_emptyCOMBOfirst_frame3 options: first_frame, all_frames, blank

Outputs (3)

NameTypeDescription
imageIMAGE
selected_countINT
skipped_countINT