Nodes/NH-Nodes/Batch Merge (NH)
ComfyUI Node

Batch Merge (NH)

Stack three image batches into one, and it fixes the sizes for you

By jetthuangai·Created 5 months ago·Updated 21 days ago· 6
Batch Merge (NH)
  • batch_a
  • batch_b
  • batch_c
  • result
  • count
resize_modestretch

Image batches in ComfyUI are just tensors stacked along the batch axis - and that means they only stack cleanly if every image is the same width and height. The moment your batches come from different generators, different upscalers, or different sources, torch.cat throws a shape error at you and you're stuck resizing by hand. Batch Merge (NH) exists to absorb that pain: it takes up to three batches and merges them into one, quietly resizing the stragglers to match the first batch's dimensions.

Think of it as the "gather everything into one bag" node. You'll reach for it when you want a single contact sheet, a single save step, or a single downstream pass over results from multiple branches.

How it works

  • batch_a is required and defines the boss: its resolution is the target.
  • batch_b and batch_c are optional. Leave either empty and it's simply skipped.
  • resize_mode decides what happens to a batch whose dimensions don't match batch_a's:
    • stretch - force to target size, distorting aspect ratio if needed. Fast and simple; can squash faces if ratios differ wildly.
    • crop - scale to cover the target, then center-crop the overflow. No distortion, but you lose the edges.
    • pad - scale to fit inside, then pad with black to fill the gap. No distortion, no data loss - just letterbox bars. The pick for most compositing uses.

The output result is the merged batch, and count tells you the total number of images that ended up in it.

A useful detail: matching-size batches pass through with zero resampling, so if you keep resolutions consistent upstream this node is essentially free - the resize path only fires for actual mismatches.

Where you'll actually use it

  • Combine "generated variation" batches from two different prompts into one batch for a single Image Grid Composite (NH) contact sheet.
  • Merge the outputs of parallel branches before a shared save or preview node.
  • Batch-A/B comparisons: generate batch A and batch B, merge them, and feed a compare or grid node once.

Installing

Same pack, one-time setup:

cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt

Or search NH-Nodes in ComfyUI Manager and restart. Pure tensor handling - no models, no downloads. If you see unexpected aspect distortion, check that you're not in stretch mode with wildly different source ratios; pad is almost always the safer default.

CategoryNH-Nodes/Batch

Inputs (4)

NameTypeDefaultDescription
batch_aIMAGE
batch_boptIMAGE
batch_coptIMAGE
resize_modeoptCOMBOstretch3 options: stretch, crop, pad

Outputs (2)

NameTypeDescription
resultIMAGE
countINT