Image List Slice (XJ)
Carve a range out of your image list like Python slicing
- image_list
- list
You've built up a list of images and you don't want all of them - the first few are throwaways, or you only want the middle stretch, or you want everything after a certain point. XJImageListSlice is the pack's list-slicing node: give it start and end and it returns the images in that range, mirroring Python's list[start:end] semantics.
It's part of the ComfyUI-XJNodes image-list family, and it's the node that turns a raw accumulation into a usable selection. Common uses: drop the first N warm-up frames of a batch, take just the last K results from a long sweep, or chop a list of crops down to the region you actually care about. Combined with the pack's empty-list/append nodes, it closes the loop on list manipulation - build, measure, index, slice.
How it works
The behavior is deliberately Pythonic:
start(default 0) is the first index included.end(default -1) is the first index excluded - and-1means "all the way to the end" here, not "one before the end." So the default slicestart=0, end=-1returns the whole list. That's the one semantic quirk to internalize: in this node,-1is a sentinel for "the end," becauseend=-1as an exclusion would otherwise return an empty slice.- Out-of-range values are validated and rejected with clear errors, rather than silently trimming.
Bounds checks are strict: start must be within the list, and end must be between start and the list length, or you get an explicit error message telling you the list size. This is friendlier than Python, which would silently clamp.
The output is a list type (list), so it chains cleanly back into the pack's other list nodes or into a saver that accepts lists.
The inputs and outputs
image_list(IMAGE, list) - what you're slicing.start(INT, default 0) - first index to keep.end(INT, default -1) - last index plus one;-1means the end of the list.- Output:
list(IMAGE, list) - the selected range.
Installing it
Part of ComfyUI-XJNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
then restart ComfyUI (or ComfyUI Manager → ComfyUI-XJNodes). No models, no dependencies.
Common issues
The end = -1 sentinel is the trap - if you come from Python you'll read it as "exclude the last element," but here it means "through the end." And because bounds are checked loudly, an empty or too-small list will raise rather than returning a truncated slice, so guard with a length check when your list size is uncertain. It's a small node with exactly two knobs, and once the -1 quirk is in your head, the rest is pure Python you already know.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image_list | IMAGE | — | |
| start | INT | 00–10000 | — |
| end | INT | -1-1–10000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| list | IMAGE | — |