Nodes/ComfyUI-ImageBatchUtils/🔢 Image Batch Count
ComfyUI Node

🔢 Image Batch Count

Count your images in ComfyUI before they bite you

By xuxiao305·Created 5 months ago·Updated 5 months ago· 0
🔢 Image Batch Count
  • images
  • INT

The most boring node in ComfyUI-ImageBatchUtils is also the one you'll end up reaching for during debugging more than any other. ImageBatchCount takes a batch and tells you how many images are in it, as an INT. That's it. But "that's it" hides how often the answer surprises you, and how often a workflow breaks precisely because nobody checked.

What it does

One input, images (IMAGE), one output, INT. Counts the batch size - the B in that [B, H, W, C] shape every image batch carries. Like the rest of this pack it handles list inputs too: if you feed it a LIST[IMAGE] from something like SEGSPreview, it sums the counts across every item in the list, so you always get the real total. Empty input returns 0 instead of erroring, which is more graceful than a lot of core nodes.

Where it earns its keep

The honest answer is: debugging and conditional logic, not art.

  • Debugging. You think you asked for four images and you got four. Then a count node tells you it's actually three because one batch node quietly dropped a frame or a segment detection came back short. Wiring a count node into a Preview and watching the number is the cheapest sanity check in ComfyUI.
  • Conditional gating. Feed the INT into any node that takes an integer and does something only when a condition is met - "if the batch is bigger than N, run the upscaler; otherwise skip it." Batch size becomes a first-class condition in your graph instead of a mystery.
  • Before you unpack. This pack's own unpack and slice nodes happily handle any batch size, but their downstream branches often assume a specific count. Count first, then slice or branch accordingly. It's the guard rail that makes the sibling nodes safe to use.

Install

Same as every node in this pack - it's genuinely dependency-free, MIT, no model files:

cd ComfyUI/custom_nodes
git clone https://github.com/xuxiao305/ComfyUI-ImageBatchUtils

restart ComfyUI, and the whole family appears together in the node menu under image/batch (and mask/batch for the mask one). Or search ComfyUI-ImageBatchUtils in ComfyUI Manager and let it handle the clone and any updates. There's no requirements.txt to fight with, no Python version roulette - this is the rare custom node you can install with zero anxiety.

Gotchas

Keep your expectations honest. This counts items in the batch, not unique images - ten near-duplicate latents still count as ten. And the INT it outputs is just a number; whether anything downstream listens to it is up to you. It won't fix a workflow that's ignoring its own counts. But it'll show you the number that workflow is ignoring, which is usually the first step to fixing it.

Categoryimage/batch

Inputs (1)

NameTypeDefaultDescription
imagesIMAGE

Outputs (1)

NameTypeDescription
INTINT