ComfyUI Node

CombineMasks

Merge two masks into one

By al-swaiti·Created 2 years ago·Updated 2 months ago· 185
CombineMasks
  • mask1
  • mask2
  • mask

This is a plumbing node, and a genuinely useful one. It takes two masks and unions them into a single mask. That's it - but it's the piece that makes text-prompted masking actually practical, because the natural way to select several things is to select each one separately and then join them.

Its class name is CombineSegMasks; ComfyUI shows it as CombineMasks. Same node.

Why you'd use it

The pack's CLIPSeg node masks one named concept at a time - you give it a single word and get a mask back. So the moment you want to edit "hair and jacket" or "sky and water" together, you're stuck with two masks and no single selection. CombineMasks fixes that: run CLIPSeg twice, feed both results in here, and you get one mask covering both regions to hand to your inpaint or composite step.

It's the same idea as the mask-combine utilities in ComfyUI core and the Impact Pack; this is just the version that lives inside the OllamaGemini pack, so you don't have to reach outside it if that's the only pack you've got installed.

How it works

It merges the two inputs into one - a union, where any pixel that's masked in either input is masked in the output. There's no subtract or intersect mode exposed here; it's an OR, not a full boolean toolkit.

The inputs and outputs

There are only three ports, and nothing to configure:

  • mask1 and mask2 - the two MASK inputs to join.
  • mask - the single combined MASK output.

Wire the output into whatever consumes a mask: a Set Latent Noise Mask for inpainting, a composite, or another CombineMasks if you're stacking more than two.

Installing it

It comes with the ComfyUI-OllamaGemini pack. Install via ComfyUI Manager (search ComfyUI-OllamaGemini, install, restart) or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
pip install -r requirements.txt

then restart. This node pulls no models and needs no keys - it's pure array math on masks you already have.

Where people get burned

Two small things. First, it only takes two masks. To combine three or more, chain the node: feed mask1 and mask2 in, then feed that output plus a third mask into a second CombineMasks. It composes fine, it just doesn't take a list.

Second, the two masks should be the same dimensions. If you generated them from differently-sized images they may not line up, and you'll get a mask that's offset or clipped rather than an error - so keep your mask sources at a consistent resolution. And if you specifically need subtract (remove one region from another) or intersect (keep only the overlap), this node won't do it; you'll want a mask node from core or the Impact Pack that exposes those operations. The pack also registers an identical Gemini Combine Seg Masks twin in a different menu; either one does the same union.

Categoryimage

Inputs (2)

NameTypeDefaultDescription
mask1MASK
mask2MASK

Outputs (1)

NameTypeDescription
maskMASK