Nodes/ComfyUI-ZhiHui/📦 智绘_制作批次
ComfyUI Node

📦 智绘_制作批次

Up to 20 loose images, one batch — with free size-matching

By zhuyungen·Created 8 months ago·Updated 4 months ago· 0
📦 智绘_制作批次
  • 📸 图像1
  • 📸 图像2
  • 🖼️ 图像批次
  • 📊 图像数量

Some nodes want a single image, and some want a batch - and plenty of the best ones (grid assemblers, batch upscalers, KSamplers processing multiple variants) want the latter. ZH_MakeBatch ("📦 智绘_制作批次") is the glue: it takes up to 20 separate image inputs and fuses them into one batch along the batch dimension, automatically resizing any stragglers so the stack doesn't explode.

It's part of ComfyUI-ZhiHui, a Chinese-language utility pack that imported a chunk of Dapao-Toolbox - this node's lineage is right there in the author's integration notes. It's the kind of plumbing node nobody writes articles about and everybody eventually needs.

How it works

Collect inputs 📸 图像1 … 📸 图像N, drop the unconnected ones, and torch.cat the rest along dimension 0. The one clever bit: if images disagree on size, it resizes the smaller ones to match the first image's dimensions using bilinear interpolation before stacking, so you don't hit the "all tensors must be the same shape" error that kills plain torch.cat workflows. The frontend starts with two inputs and reveals more as you connect them, up to 20.

The inputs and outputs that matter

  • 📸 图像1 … 📸 图像N - optional IMAGE inputs; connect as many as you need, skip the rest.

Outputs: 🖼️ 图像批次 (IMAGE - the merged batch, so a downstream node runs once over all of them) and 📊 图像数量 (INT, the batch size). The count output is worth wiring somewhere, because silent mismatches are exactly what this node exists to paper over.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git

Restart ComfyUI. Base deps (torch, numpy, Pillow) only, no models. ComfyUI Manager search "ComfyUI-ZhiHui" also works.

Where people get burned

The auto-resize is convenient and slightly dangerous: it stretches non-matching images to the first image's size - it does not letterbox or crop, so aspect ratios get warped. The author's own warning is "缩放可能改变宽高比" (scaling may change the aspect ratio), which is developer-speak for "your square images will look squished next to your landscape ones." If aspect ratio matters, pre-normalize with a pad/crop node first (the pack's ZH_LoadFolder has proper fit modes for exactly this). Also, no inputs at all raises a hard error rather than returning a blank - so keep at least one image wired, and if you're building a graph with optional branches, consider a first-non-null switch upstream to guarantee a live input.

Category智绘灵箱

Inputs (2)

NameTypeDefaultDescription
📸 图像1optIMAGE第1张图像(可选)
📸 图像2optIMAGE第2张图像(可选)

Outputs (2)

NameTypeDescription
🖼️ 图像批次IMAGE—
📊 图像数量INT—