Nodes/WtlNodes/Mask Batch
ComfyUI Node

Mask Batch

Stack masks into one batch — cropped to the first mask's size

By Scorpiosis0·Created 10 months ago·Updated 2 months ago· 3
Mask Batch
  • mask_1
  • mask_2
  • batch (crops to mask 1 size)

WtlMaskBatch is the mask-flavored version of the pack's Image Batch node: it takes multiple masks, stacks them into a single MASK tensor, and forces them all to the dimensions of the first one. If you've got per-frame masks from a video pipeline, or a pile of region masks from a detector that need to feed a batch operation as one unit, this is the merger.

Wire up mask_1, mask_2, and keep connecting - new slots appear automatically as you go, same dynamic-input behavior as its image sibling. The output port is named "batch (crops to mask 1 size)", and that's the entire contract spelled out: everything you connect gets scaled-then-center-cropped to match mask_1's resolution. The mechanism is ComfyUI's own default batch normalization - comfy.utils.common_upscale with bilinear and center crop - so a mask that isn't already the right size is resized and center-cropped to fit, and the whole stack becomes one tensor downstream nodes can consume at once.

Why do it? Most nodes that operate on masks in a batch want them in a single tensor rather than a list of separate masks - things like batch inpainting, animation pipelines, or feeding a set of region masks into a filter that expects one batch. Without a merger you're either fighting type errors or writing a glue node; this is the clean path.

The trade-off is the crop, and it's worth being explicit about: center-cropping means edge pixels can get cut, so masks that don't share the first mask's aspect ratio will lose content. If preserving every mask at its original size matters more than uniformity, use the pack's Mask Combiner instead, which keeps original dimensions and outputs a list. WtlMaskBatch is the "I accept the crop, give me one uniform tensor" option - same division of labor as Image Batch vs. Image Combiner.

It ships in the WtlNodes pack (Scorpiosis0/ComfyUI-WtlNodes). Install via ComfyUI Manager by searching "WtlNodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Scorpiosis0/ComfyUI-WtlNodes.git

then restart ComfyUI. Deps: numpy, scipy, pillow. No models, no downloads.

Remember the naming rule so you grab the right one: Batch = one stacked tensor, cropped to the first input; Combiner = a list, sizes preserved. For masks doing batch work, it's usually Batch you want.

CategoryWtlNodes/mask

Inputs (2)

NameTypeDefaultDescription
mask_1MASK
mask_2MASK

Outputs (1)

NameTypeDescription
batch (crops to mask 1 size)MASK