Nodes/ComfyUI-DD-Nodes/DD Mask Uniform Size
ComfyUI Node

DD Mask Uniform Size

Resize four masks to match your images, without turning edges to mush

By Dontdrunk·Created 2 years ago·Updated 21 days ago· 181
DD Mask Uniform Size
  • 遮罩A
  • 遮罩B
  • 遮罩C
  • 遮罩D
  • 遮罩A
  • 遮罩B
  • 遮罩C
  • 遮罩D
缩放方法邻近-精确
宽度512
高度512
尺寸适配自适应
阈值处理false
阈值值0.50

The mask sibling of DD Image Uniform Size, and the one that fixes a silent killer of inpainting workflows: a mask resized with soft interpolation becomes a blurry gradient, and your inpaint region starts feathering where it should be hard-edged. DD Mask Uniform Size resizes up to four masks to a target width and height - and it defaults to nearest-neighbor interpolation precisely so those edges stay crisp.

How it works

The layout mirrors the image version exactly: 宽度 (Width) and 高度 (Height) define the target, 尺寸适配 (Size Fit) picks adaptive/stretch/crop/fill, and 缩放方法 (Scaling Method) selects the interpolation. The big difference is the default: where the image node defaults to bilinear, this one defaults to 邻近-精确 (nearest-exact) - the right call for masks, since soft resampling bleeds 0.5-gray values into a region that should be binary. Use bilinear or bicubic here only if you genuinely want a soft-edged mask.

The mask-specific extras are the second difference: 阈值处理 (Threshold Processing) and 阈值值 (Threshold Value, 0–1, default 0.5). Flip thresholding on and any pixel above the threshold snaps to fully white, below snaps to fully black. That's your safety net - resize a mask, get a muddy edge, and threshold it back to a clean binary silhouette in one pass. It's a pragmatic touch that the image version doesn't have, and it tells you the author has actually hit this problem.

Inputs are 遮罩A through 遮罩D (four optional MASK ports), outputs are the four resized masks. Only connected ports produce output, same as the image twin, so you wire exactly what you have.

When you'd reach for it

The canonical workflow: you upscale or resize an image (with DD-ImageUniformSize or anything else), and the mask that came with it now points at the wrong dimensions. Run the mask through this node with the same target width/height and the same fit mode, and it lines back up pixel-for-pixel. That image-and-mask pair is the backbone of region-based workflows - inpainting, ControlNet masking, IP-Adapter region control - and mismatched mask dimensions are one of the most common "why is my inpaint ignoring my mask" causes.

Installation

One-pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/Dontdrunk/ComfyUI-DD-Nodes
cd ComfyUI-DD-Nodes && pip install -r requirements.txt

Restart ComfyUI or use ComfyUI Manager (search "ComfyUI-DD-Nodes"). No models needed.

Where people get burned

The trap is using the image node's defaults on masks. If you resize a mask with bilinear and don't threshold, you'll quietly get a feathered region that behaves differently from what you drew. The fix is either this node's nearest default or flipping 阈值处理 on. Also keep the fit mode consistent with however you resized the image - a "stretch" image wants a "stretch" mask, or they drift apart. Labels are Chinese by default; the pack ships an English locale in ComfyUI's settings.

Category🍺DD系列节点

Inputs (10)

NameTypeDefaultDescription
缩放方法COMBO邻近-精确5 options: 邻近-精确, 双线性插值, 区域, 双三次插值, lanczos
宽度INT5128–8192
高度INT5128–8192
尺寸适配COMBO自适应4 options: 自适应, 拉伸, 裁剪, 填充
阈值处理BOOLEANfalse
阈值值FLOAT0.500–1
遮罩AoptMASK
遮罩BoptMASK
遮罩CoptMASK
遮罩DoptMASK

Outputs (4)

NameTypeDescription
遮罩AMASK
遮罩BMASK
遮罩CMASK
遮罩DMASK