Nodes/ComfyUI-Counternodes/Interval Image Counter
ComfyUI Node

Interval Image Counter

Counts how many times an image passes through — without touching a single pixel

By GHOSTLXH·Created 2 years ago·Updated 2 years ago· 11
Interval Image Counter
  • image
  • trigger
  • image
  • count
resetfalse
increment1
trigger_interval1

Most counter nodes tick on time or on queue runs. This one ticks on a specific thing: an image moving through its image port. That's the entire trick, and it's exactly what you want when you're iterating through a folder of reference images - each new image that flows through the node advances the count, and the image itself comes out the other side completely untouched.

It's the middle piece of the pack's signature workflow: feed it a stream of reference images, and its count output tells you which image you're on. Pair it with Load Prompt from TXT (same pack) and you can pull the prompt that belongs to that image, so every reference image arrives with its own matching text. That's the folder-traversal loop the README keeps pointing at.

How it works

Each execution with an image bumps an internal interval counter. When it reaches trigger_interval, the node adds increment to count and resets the interval. Set trigger_interval to 1 (the default) and it counts every single image; set it to 3 and only every third image advances the count - same idea as the pack's Interval Counter, but triggered by images instead of executions.

reset is a boolean that zeroes count and the interval, so you can restart a folder pass cleanly. There's also an optional trigger input, but the README is blunt: don't connect it. It's just a marker - the triggering is already built into the image port.

Inputs and outputs that matter

The required inputs are image (any IMAGE tensor), reset, increment (1–100), and trigger_interval (1–10000). Two outputs: image - the exact input, passed through byte-for-byte - and count, an INT that tells you how far along you are.

Wire count into the index and trigger inputs of Load Prompt from TXT. Feeding both matters: index picks the prompt, and the changing trigger value is what forces the node to re-run instead of returning a cached result. On the image side, image can go anywhere you'd send a reference - an IPAdapter, an img2img encoder, a batch loader's output chain.

Installing it

It's in the ComfyUI-Counternodes pack, so install once and all six nodes show up. ComfyUI Manager: search ComfyUI-Counternodes. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/GHOSTLXH/ComfyUI-Counternodes

Then restart ComfyUI. No models to download, no extra dependencies beyond what ComfyUI already ships.

Gotchas worth knowing

The big one: the image input is the trigger, which means the image actually has to change between runs. If you feed it the same single image every time, ComfyUI caches the node and the count never moves. Feed it a real stream - a Load Image list, a folder loader, whatever's actually advancing.

Second, if you're pairing it with Interval Counter, keep increment and trigger_interval identical on both nodes - the README calls this out explicitly, and mismatched values will desync your image-to-prompt pairing midway through a folder.

Finally, like the rest of the pack, its state persists to a JSON file in the pack directory (image_counter_state.json), so the count survives restarts and leaks between workflows. When a pass looks like it started mid-way, that's why - flip reset true once and you're back at zero.

Categoryimage

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
resetBOOLEANfalse
incrementINT11–100
trigger_intervalINT11–10000
triggeropt*

Outputs (2)

NameTypeDescription
imageIMAGE
countINT