Nodes/ComfyUI 1hewNodes/Int Image Count
ComfyUI Node

Int Image Count

Count the real images in a batch — ignoring empty frames and pure-black junk

By 1hew·Created about a year ago·Updated 7 days ago· 33
Int Image Count
  • image_1
  • int

Sometimes you just need to know how many images you have. Not because you can't count, but because in a big workflow the count is usually a runtime fact - a video decoded into N frames, a folder that loaded M images, a batch that some node shrank or padded - and you want that number as an INT you can feed into other math. That's this node's whole job, and it does it with a couple of sensible opinions about what counts as "an image."

The pack added it alongside a wave of batch/image-count utilities in v3.14.0, and it fills a real gap: ComfyUI's default introspection is clunky, and when you're building loops ("process 100 frames, in chunks of 8"), an accurate count wired straight into the graph beats eyeballing it.

How it works

It accepts dynamic inputs image_1, image_2, ... image_N - plug in as many image sources as you like. For each one it counts valid frames, and here's where the opinions come in:

  • Empty tensors don't count. A node that outputs a 0-length batch contributes nothing.
  • All-black tensors don't count. _count_valid_images checks whether the entire tensor is zeros and skips it if so. That's a practical filter: many pipelines emit placeholder/black frames for missing slots, and this treats them as "not really there."
  • Multi-frame batches count each frame, so a 24-frame video input counts 24, not 1.

Output is a single INT plus a small text readout on the node so you can see the count at a glance without wiring anything.

The practical use case: feed it the same batch that's going into your sampler loop, take the int output, and use it for batch-size math or to decide how many iterations a "for each chunk" pattern needs. It also quietly ignores unconnected optional inputs - image_1 is optional, so you can start with one source and add more as the graph grows.

Installing it

It's part of the 1hewNodes pack. ComfyUI Manager → search "ComfyUI 1hewNodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart ComfyUI. Zero special dependencies for this node, no model downloads.

Common issues

The black-frame heuristic is the thing to keep in mind: if you legitimately generate an all-black image (a proper black frame for a fade-to-black edit), it won't count it. For almost everyone that's a feature, but if your workflow is built around legitimately dark frames, this count will quietly disagree with your expectations. Also, because inputs are dynamic, the node only counts what's actually connected - an image that reaches the node through a list rather than a batch won't be seen, so convert lists to batches first if that's your setup.

Category1hewNodes/int

Inputs (1)

NameTypeDefaultDescription
image_1optIMAGE

Outputs (1)

NameTypeDescription
intINT