GetImageBatchSize
GetImageBatchSize – ComfyUI Node
- image
- number
- int
- float
What it is
GetImageBatchSize answers one question: how many images are actually in this batch? ComfyUI's IMAGE type is always a batch under the hood - even a single loaded image is technically a batch of one - and most of the time you never need to think about that. You start needing to think about it the moment you're building something conditional or iterative around a batch: looping over every image one at a time, checking whether a batch is empty before doing expensive work, or driving a counter that needs to know when to stop. This node hands you that count as a number, so you can wire it into comparisons, math nodes, or loop-control logic instead of eyeballing it.
How it works
It reads the batch dimension off the incoming IMAGE tensor and returns it as a count - no processing of the image content itself, no per-image work. It's cheap, and it's meant to be used purely for control-flow decisions elsewhere in the graph.
Inputs and outputs
One input: image (IMAGE, required) - any batch of images, size one or larger.
Three outputs, all carrying the same value in different types so you don't need a separate conversion node depending on what the next node expects: number (NUMBER), int (INT), and float (FLOAT). Wire whichever matches the type your downstream node actually wants - this pack's own InnerIntCompare and InnerIntMathOperation nodes, for instance, want INT specifically.
Installing it
Ships as part of comfyui-easyapi-nodes. Through ComfyUI Manager: search "comfyui-easyapi-nodes", install, restart. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt
This node needs nothing exotic - it's reading a tensor shape - but run the requirements install anyway so the rest of the pack (some of it does have real dependencies) isn't left half-working. git pull in the folder later to upgrade.
Common issues
"I'm getting 1 when I expected more (or vice versa)." This is almost always upstream of the node, not a bug in it. If you loaded a single image and expected a batch of several, check what actually produced the IMAGE - a single LoadImage gives you a batch of one regardless of what the file looks like; you need something that explicitly batches multiple images together (or a loop wired up to process one-by-one and accumulate) if you want a genuinely multi-image batch.
"Which of the three outputs should I use?" Whichever type the next node in line expects. INT is the one you'll want for loop counters and comparisons against this pack's InnerIntCompare/InnerIntMathOperation nodes; FLOAT if you're feeding something that does floating-point math; NUMBER is ComfyUI's own generic numeric widget type, useful if you want the value to also be editable/displayable as a widget elsewhere. All three are the same number - it's purely about matching socket types, not about getting different information.
"I want this to drive a loop that processes each image individually." GetImageBatchSize only gives you the count - pair it with this pack's for-each loop nodes (ForEachOpen/ForEachClose, or InnerLoopClose if you're managing the accumulator manually) and an index-based node like IndexOfList to actually step through the batch one image at a time.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| number | NUMBER | — |
| int | INT | — |
| float | FLOAT | — |