Nodes/ComfyUI_Yvann-Nodes/Repeat Image To Count
ComfyUI Node

Repeat Image To Count

Pad an image batch up to the frame count you need

By yvann-ba·Created 2 years ago·Updated 7 months ago· 712
Repeat Image To Count
  • image
  • images
count1

Audio-reactive pipelines have a nagging mismatch: your audio analysis produces one weight per frame for the whole clip, but the images you're animating rarely arrive in the right batch size. Repeat Image To Count fixes the boring half of that - it takes an image batch and repeats (cycles) it until it hits exactly the count you specify.

The mechanism

One input, one setting:

  • image - a batch of images (the IMAGE type).
  • count - the target number of output images (default 1, minimum 1).

If count is greater than the batch size, the node cycles through the images in order - image 0, 1, 2, 0, 1, 2... - until the output batch has exactly count images. If count is smaller than the batch, it truncates (the code just indexes the first count). The output images always matches the requested count exactly.

Under the hood it's a modulo index into the batch, so it's instant and lossless - no resizing, no blending, the source images are untouched.

Why you'd reach for it

The canonical use is syncing an image batch to an audio frame count. Say your video runs 96 frames but you have 4 reference images: set count to 96 and you get 96 frames cycling through your 4 images - perfectly aligned with the per-frame weights from Audio Analysis downstream. It's also handy for:

  • Batching up a single image to match a batch-size-hungry node (set count to your latent batch size).
  • Trimming a batch to an exact length for a node that demands one.
  • Loop preparation - repeat a short clip's keyframes to the full animation length.

Gotchas

  • It cycles, it doesn't hold. To repeat the last image (hold the final frame) instead of looping back to the first, this isn't the node - it will wrap around. "Repeat" here means "cycle," not "freeze."
  • Count smaller than batch = truncation. It silently drops the tail, which is usually what you want, but worth knowing if you were expecting padding.
  • The count is a required input, so wire it from a number you control (or a frame count computed elsewhere) rather than hardcoding and forgetting.

Install

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/yvann-ba/ComfyUI_Yvann-Nodes

or ComfyUI Manager → search ComfyUI_Yvann-Nodes. No dependencies beyond torch. It's the least glamorous node in the pack and arguably the one that prevents the most silent "frame count mismatch" errors - batch sizes are the classic place audio-reactive graphs break, and this is the duct tape that fixes them.

Category👁️ Yvann Nodes/🛠️ Utils

Inputs (2)

NameTypeDefaultDescription
imageIMAGEBatch of images to repeat
countINT1Number of output images (cycles if count > batch size)

Outputs (1)

NameTypeDescription
imagesIMAGE