Nodes/ComfyUI 1hewNodes/Multi Mask Batch
ComfyUI Node

Multi Mask Batch

Several masks of different sizes, one tidy batch

By 1hew·Created about a year ago·Updated 7 days ago· 33
Multi Mask Batch
  • mask_1
  • mask
fitpad
pad_color0.00

Batches require uniform shapes. Masks from real workflows rarely are - one from a segmentation node is 1024², one you drew in an editor is 512², one came from a cropped region. Multi Mask Batch takes any number of mask inputs of whatever sizes and squashes them into one consistent batch, sized against the first mask you plug in. It's the mask-world equivalent of "get everyone on the same canvas before we start."

How it works

The first connected mask establishes the reference H × W. Every other mask is then unified to it through the fit strategy you pick:

  • pad (default) - scale to fit inside the reference, keeping aspect ratio, then center-pad the rest with pad_color. Nothing gets cropped away; you just get borders.
  • crop - scale to fully cover the reference, keeping aspect ratio, then center-crop the overflow. You lose the edges but never see padding.
  • stretch - ignore aspect ratio and force the exact reference size. Fast, but distorts.

All resizing is bilinear, and outputs are clamped to 0–1 (so pad_color above 1 or below 0 gets pulled back into mask range). pad_color defaults to 0 - i.e. padded areas are "outside," which is the semantically correct choice for masks. Set it to 1 if you'd rather padding count as covered.

The inputs that matter

  • mask_1 (MASK, required) - sets the reference size everything else conforms to.
  • mask_2 … mask_N - the rest, added as you drag wires in.
  • fit - pad / crop / stretch, above.
  • pad_color (FLOAT, default 0) - the fill for padded areas (0 = outside, 1 = inside).

One output: mask (MASK), the unified batch.

Installing it

ComfyUI Manager → search ComfyUI-1hewNodes → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart ComfyUI. No model downloads - tensor + torch.nn interpolation only. Pack pulls heavy pip deps anyway, and it needs a current ComfyUI (comfy_api.latest API).

Common issues

The reference-size gotcha is real: whatever mask is in mask_1 dictates the batch dimensions, and it's easy to forget that changing mask_1 reshapes everything downstream. Also, pad vs. crop changes which pixels survive: with pad, content is preserved but offset into a canvas; with crop, the center is kept but edges vanish. If masks come from sources with different aspect ratios, stretch is the tempting option but produces visibly warped regions - better to pad and accept the borders. And remember masks are normalized to 0–1, so if you were relying on a 255-scale mask value for something exotic, it's getting clamped.

Category1hewNodes/multi

Inputs (3)

NameTypeDefaultDescription
fitCOMBOpad3 options: crop, pad, stretch
pad_colorFLOAT0.000–1
mask_1MASK

Outputs (1)

NameTypeDescription
maskMASK