Nodes/ComfyUI Level Pixel/Image Data Iterator [LP]
ComfyUI Node

Image Data Iterator [LP]

Image Data Iterator [LP] — ComfyUI Node Guide

By LevelPixel·Created 2 years ago·Updated 6 months ago· 31
Image Data Iterator [LP]
  • iterator_data
  • item_index
  • set_index
  • set_name
  • global_index
global_index0

This is the "give me item number N" half of LevelPixel's manual loop system. GetIteratorDataImageFolders (or GetIteratorDataVideos) does the scanning and builds a manifest; this node takes that manifest plus a running index and tells you exactly which item and which folder you're on for this pass through the queue.

What it does

Feed it iterator_data from one of the scanner nodes and a global_index - the position you're at across the whole flattened dataset, not per-folder - and it works out where that lands: which set (subfolder) it falls in, the position within that set, and the position overall. On its own it doesn't load an image; it resolves which image you're currently pointing at, which is the piece that lets you drive an actual loader node (elsewhere in your graph) to a specific file on each queue run.

This is the node that makes "process every image in every subfolder, one queue run per image" actually workable instead of a manual slog. Combine it with the control_after_generate: increment trick on an INT primitive feeding global_index, and each time you queue the prompt you move one item further through the dataset.

Inputs and outputs

  • iterator_data (ITERATOR_DATA) - the manifest from GetIteratorDataImageFolders or GetIteratorDataVideos. This is a custom type, so it only connects from those scanner nodes.
  • global_index (INT, default 0, min 0) - your current position across the entire dataset. Wire an incrementing INT primitive here to drive the loop forward one item per queue.

Outputs:

  • item_index (INT) - position within the current set (folder).
  • set_index (INT) - which set (folder) this item belongs to.
  • set_name (STRING) - the folder's name, useful if you want to route output files back into a folder named after where they came from.
  • global_index (INT) - passes your input index straight back through, handy for wiring into a display node or a filename without a second primitive.

Installing it

ComfyUI Manager: search "ComfyUI-LevelPixel" (listed as "Level Pixel"), install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git into your custom_nodes folder, then restart ComfyUI. No model downloads, no extra dependencies for this one specifically - it's pure indexing logic.

Common issues

The outputs here are indices and a name, not pixel data - a common first-time confusion is expecting IMAGE out of this node and not getting it. You still need a loader node downstream that actually knows how to turn set_name and item_index into a loaded image; this node's job stops at telling you which one.

If global_index runs past the end of what iterator_data actually contains (say you queue 50 times but the folder only had 30 images), don't expect graceful looping back to the start - check your image_count or folder_count from the scanner node before setting your queue count, and keep the two numbers in sync rather than guessing.

Because ITERATOR_DATA is a bespoke type specific to this pack, it won't connect to anything except the LevelPixel nodes built to produce or consume it - if a wire refuses to connect, that's ComfyUI's type system doing its job, not a bug. And remember rescan_each_queue on the upstream scanner node changes what iterator_data actually contains between runs - if you're seeing indices point at unexpected files mid-loop, check whether the folder contents shifted and the scanner re-walked it under you.

CategoryLevelPixel/Iterators

Inputs (2)

NameTypeDefaultDescription
iterator_dataITERATOR_DATA
global_indexINT0

Outputs (4)

NameTypeDescription
item_indexINT
set_indexINT
set_nameSTRING
global_indexINT