ComfyAngel_GetLength
'how many things am I looping over?'
- items
- INT
One input, one output, one question answered: how many items is this? ComfyAngel_GetLength takes any items value and returns its length as an INT. It's hidden from the node menu (deprecated, internal), and it's the thing that tells Loop End how many passes a loop needs before it stops.
The length rules, exactly as the code defines them
Because items is ANY, the node has to make sense of whatever lands in it, and the rules are simple:
- A tensor (an IMAGE batch, a MASK, a LATENT's samples): the length is the batch dimension, i.e. the first dimension of the shape. A
(4, H, W, C)image tensor reports 4. - A list or tuple: plain
len(). - A single value that isn't a list: reports 1.
None: reports 0.
So it genuinely answers "how many things am I looping over" for every input the loop nodes accept - which is the whole point. When you feed Loop Start an image batch from Load Images Batch from Folder, GetLength is what lets Loop End compute total and then repeatedly ask Compare "are we still under it?" That's the loop's exit condition in one node.
Using it outside a loop
It's an internal node, so you usually meet it only through loops or by loading a workflow that contains one. But honestly, it's the cleanest "count my batch" node in the pack, and if you enable "Show deprecated" in the node search you can drop it anywhere: feed it an image batch and you get the batch size as a plain INT you can wire into a filename, a progress display, or a conditional. It's the only easy way in this pack to get batch count as a number without doing the math yourself.
Installing it
ComfyAngel installs like any custom node pack:
cd ComfyUI/custom_nodes
git clone https://github.com/ThepExcel/ComfyAngel.git
Restart ComfyUI, or search "ComfyAngel" in ComfyUI Manager. Dependency footprint is a single line - Pillow - and there are no model downloads to worry about.
One trap worth naming: if items is a tensor, GetLength counts the batch dimension, not the number of distinct-sized elements. Feed it a list of five differently-sized image tensors and it reports 5; feed it one batched tensor of the same five and it still reports 5 - but the loop will hand you different things in each case. Know which shape you're feeding it, and the number will never surprise you.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| items | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |