Nodes/Nilor Nodes by Nilor Corp/๐Ÿ‘บ Repeat & Trim Image Batch
ComfyUI Node

๐Ÿ‘บ Repeat & Trim Image Batch

Pad any image batch up to a fixed count โ€” deterministically, no shuffling

By nilor-corpยทCreated 2 years agoยทUpdated 5 months agoยท 6
๐Ÿ‘บ Repeat & Trim Image Batch
  • images
  • images
โ—„count1โ–บ

Sometimes you need exactly N images and you don't care about the order - you just need the count to be right so a downstream node stops complaining. ๐Ÿ‘บ Repeat & Trim Image Batch is the boring, reliable version of that job: it repeats your source batch until it has at least count images, then trims the stack down to exactly count. No shuffle, no randomness, deterministic every run. If you feed it a batch of 4 and ask for 10, you get [1,2,3,4,1,2,3,4,1,2] - simple, predictable, done.

That predictability is the feature. Where its shuffled sibling (๐Ÿ‘บ Repeat, Shuffle, & Trim Image Batch) is for data-mixing and augmentation-style work, this one is for batch padding and fixed-size plumbing: a node needs 8 frames, you've got 5, you pad to 8. It's also handy when you want the first images of your batch to stay first - say you're prepending a reference frame to a video clip and need a specific frame count. No order scrambling means the head of your batch stays put, which matters for anything where frame position carries meaning.

The mechanism is a clean tile-and-truncate: compute how many whole repeats you need to reach the count, torch.cat the tiled batch, then slice off the tail. Cheap, fast, and it keeps your batch dimensions identical to the source - same height, width, and channels, just a different batch length.

Inputs and output

  • images - your source IMAGE batch.
  • count - the exact number of images you want out (minimum 1, no practical ceiling).
  • images (output) - a batch of exactly count images, same per-image dimensions as the input.

Two inputs, one output. If the output count isn't what you asked for, the count field is the only thing you can have mis-set.

Installing it

Part of Nilor Nodes (nilor-corp/nilor-nodes):

cd ComfyUI/custom_nodes
git clone https://github.com/nilor-corp/nilor-nodes

or ComfyUI Manager โ†’ search "Nilor Nodes" โ†’ install โ†’ restart. No model files to download. The README lists Kijai's comfyui-kjnodes as a prerequisite, and the pack installs a heavy dependency stack (boto3, fastapi, huggingface_hub, openexr) whether you use it or not.

Troubleshooting

The source rejects an empty or non-4D batch up front, so the usual error is a 3D single image or a zero-frame tensor - add a batching step first. And the same honesty as its shuffled cousin: this node duplicates, it doesn't invent. A batch of 1 asked for count 10 is the same frame ten times, and for video or any per-frame-sensitive consumer that will produce nonsense. No community threads exist for this pack, so when in doubt, the error message (prefixed ๐Ÿ›‘ Nilor-Nodes) and the source code are your docs. If the tail of your batch matters more than the head, remember the trim cuts from the end - order your sources so the frames you want to keep come first.

CategoryNilor Nodes ๐Ÿ‘บ/Utilities

Inputs (2)

NameTypeDefaultDescription
imagesIMAGEโ€”
countINT11โ€“9007199254740991โ€”

Outputs (1)

NameTypeDescription
imagesIMAGEโ€”