Nodes/comfy_Pond_Nodes/🐳遮罩对齐扩展
ComfyUI Node

🐳遮罩对齐扩展

Two masks, different sizes? This is the padding node you didn't know you needed

By Pondowner857·Created about a year ago·Updated 21 days ago· 45
🐳遮罩对齐扩展
  • 基准遮罩
  • 遮罩2
  • 基准遮罩
  • 对齐后遮罩
对齐方式居中对齐

Every serious mask workflow eventually hits the same wall: two masks that should stack perfectly, from different sources, at different resolutions. Your subject mask came out of a SAM-style detector at 512px. Your canvas mask is 1024px. Feed them into a mask combine or a boolean op and nothing lines up, because ComfyUI won't magically make them agree. MaskSizeAlign is the fix - it takes one mask, sizes it to match another, and lets you pick exactly where it lands.

It's from the 🐳 Pond Nodes pack (comfy_Pond_Nodes), a big Chinese-and-English kitchen-sink collection where the mask tools are honestly the best part. This is the entry-level member of a family; its big sibling MaskSizeAlignAdvanced does the same thing for up to five masks at once.

How it works

The mechanism is delightfully simple, which is why it's reliable. The node looks at the actual content of each mask - it finds the bounding box of every pixel brighter than a hair over black - then resizes/pads mask 2 onto a canvas the size of the base mask. The key detail: it doesn't stretch your mask's content. It keeps the shape untouched and adds black (empty) borders around it to reach the target dimensions. Black in a mask means "no coverage," so alignment choice genuinely changes your result.

The inputs and outputs that matter

The interface is minimal and all three controls matter:

  • 基准遮罩 (base mask) - the reference. Its size wins.
  • 遮罩2 (mask 2) - the one that gets aligned.
  • 对齐方式 - 9 choices: center, left, right, top, bottom, and the four corners.

Outputs are 基准遮罩 (your base mask, passed through untouched) and 对齐后遮罩 (the aligned mask 2). Wire the aligned one into whatever combine, boolean, or composite node you were fighting.

Where this earns its keep: mask boolean operations with different alignments (the pack's MaskBoolean even documents 9 alignment modes), compositing masks from different detectors before an inpainting pass, and any regional workflow where the subject should stay centered on a bigger canvas.

Installing it

Same install for every node in this pack. ComfyUI Manager → search comfy_Pond_Nodes → install → restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes
pip install -r requirements.txt

Restart and it shows up under 🐳Pond/mask. Fair warning: requirements.txt installs the whole pack's dependencies (ultralytics, onnxruntime, mediapipe, realesrgan, and friends), most of which you don't need for this node. For a simple mask aligner, skip the full install and let it run on the base torch/Pillow/numpy ComfyUI already ships - the README lists those as core, and this node needs nothing else. The pack's own troubleshooting notes a conflict with comfyui_HiDream-Sampler (endless console spam); if that happens to you, check for that plugin.

The gotcha

The display name translates to "mask align expand," which sounds like it grows your mask's coverage. It doesn't. It pads around it. If you're expecting a mask to cover more of the canvas, remember you're the one who picks the alignment - a "top-left aligned" mask covers the top-left corner, a "center aligned" one covers the middle. That's the whole trick, and once it clicks you'll stop rebuilding this with half a dozen Resize + Paste nodes.

Category🐳Pond/mask

Inputs (3)

NameTypeDefaultDescription
基准遮罩MASK
遮罩2MASK
对齐方式COMBO居中对齐9 options: 居中对齐, 左对齐, 右对齐, 上对齐, 下对齐, 左上对齐, +3

Outputs (2)

NameTypeDescription
基准遮罩MASK
对齐后遮罩MASK