Nodes/TrentNodes/Multi-Batch Combine
ComfyUI Node

Multi-Batch Combine

Eight Image Batches, One Tensor, Zero Fiddly Size Matching

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Multi-Batch Combine
  • batch_1
  • batch_2
  • batch_3
  • batch_4
  • batch_5
  • batch_6
  • batch_7
  • batch_8
  • images
  • total_frames
size_modelargest
resize_methodbilinear
target_width512
target_height512

ComfyUI will happily let you wire two image batches of different sizes into a single downstream node and then fail, confusingly, deep in the graph. This node removes the whole class of problem: it concatenates up to eight image batches into one output tensor, auto-resizing anything that doesn't match, so whatever you throw at it comes out as a single uniform batch. The classic use is merging chunks of generated video frames or image sets before a single save or upscale pass.

How it works

Up to eight optional inputs (batch_1 through batch_8) - unconnected ones are simply skipped, so a graph with three batches wired and five empty is a valid graph. When more than one batch is present, it picks a target size based on size_mode and resizes everything to it with resize_method, then concatenates along the batch dimension.

The size_mode choice is the only real decision:

  • largest (default) - resize everything up to the max width and height across all batches. Nothing gets shrunk, so no detail loss on the smaller sources; the big ones stay untouched.
  • first - match the dimensions of the first connected batch. Handy when batch 1 defines the format and the others are just extras to line up with it.
  • custom - use target_width / target_height explicitly. Full control, but you have to know your numbers.

resize_method is bilinear (default), nearest, bicubic, or area. Nearest for pixel art, area for heavy downscales, bilinear/bicubic for photos. All of it runs through F.interpolate on the GPU, so the resize cost is trivial.

Two behaviors worth knowing: with a single batch connected it's a pure passthrough (returns the batch untouched plus its frame count), and with nothing connected it raises - it won't silently hand you an empty tensor. The outputs are images (the combined batch) and total_frames (its length), the latter being genuinely handy when a downstream node wants to know how many frames it's about to process.

Why you'd reach for it

The pack's own "Cowboy" loaders (Video Folder Cowboy, Image Folder Cowboy) each produce a batch per directory, and when you're mixing sources - several reference folders, multiple video clips, a few image sets - you end up with N batches that all want to be one. This is the join node. It's also the sane way to build a contact sheet or comparison grid upstream of a single grid-arrange step.

Installing it

Part of TrentNodes; one install covers the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt

ComfyUI Manager ("Trent Nodes") works too, with the recurring caveat that the author's day-one repo rename left a duplicate registry entry that occasionally makes Manager flag the pack as "unsafe" - the manual clone is the reliable fallback. Pure torch here; no model downloads.

Where people get burned

  • Unexpected resizing - default largest means every batch gets resized to the biggest, which can soften your small high-detail images. If aspect ratios vary wildly, resize is a compromise no matter what; first is the least surprising mode when one batch defines the format.
  • Forgetting the single-batch passthrough - with one batch wired it returns it unchanged, which looks like nothing happened. It didn't. That's the feature.
CategoryTrent/Image

Inputs (12)

NameTypeDefaultDescription
size_modeCOMBOlargestHow to handle size mismatches: largest (resize to max dimensions), first (match first batch), custom (use target_width/height)
resize_methodCOMBObilinearInterpolation method for resizing
batch_1optIMAGEFirst image batch
batch_2optIMAGESecond image batch
batch_3optIMAGEThird image batch
batch_4optIMAGEFourth image batch
batch_5optIMAGEFifth image batch
batch_6optIMAGESixth image batch
batch_7optIMAGESeventh image batch
batch_8optIMAGEEighth image batch
target_widthoptINT51264–8192Target width when size_mode is 'custom'
target_heightoptINT51264–8192Target height when size_mode is 'custom'

Outputs (2)

NameTypeDescription
imagesIMAGE
total_framesINT