Nodes/ComfyUI_AC_FUNV8Beta1/AC_Super_MaskScale
ComfyUI Node

AC_Super_MaskScale

Resize a mask to exact pixel dimensions

By A719689614·Created 3 years ago·Updated 4 months ago· 14
AC_Super_MaskScale
  • mask
  • IMAGE
  • MASK
upscale_method
width512
height512
crop
channel

AC_Super_MaskScale resizes a mask to an exact width and height. Masks come in all sorts of sizes from different sources - a detected face, a segmentation output, a hand-painted region - and when you need one to line up with an image at a specific resolution, this is the node that gets it there.

How it works

Internally it treats the mask as an image. A mask tensor is single-channel, so the node reshapes it into a 3-channel image, runs it through comfy.utils.common_upscale to your target width and height, then pulls the chosen channel back out as the mask. That's why it returns two things: the upscaled IMAGE and the MASK, so you can use whichever form your next node wants.

The inputs that matter

  • mask - the input mask.
  • upscale_method - nearest-exact, bilinear, area, bicubic, or lanczos. This one matters more than people expect: nearest-exact keeps mask edges hard and pixel-crisp (right for cutting), while bilinear/bicubic feather and soften them (useful when you want a gentle edge). area is a good default for downscaling.
  • width / height - target dimensions, 0 to 5277. Here's the trick: set one of them to 0 and it's computed from the other to preserve the aspect ratio. So width=1024, height=0 scales a 512×768 mask to 1024×1536 automatically.
  • crop - disabled or center. If the source aspect ratio doesn't match your target, center crops the excess from the middle; disabled squishes it.
  • channel - red/green/blue/alpha. Masks are single-channel, and since the node duplicated that one channel into three, they're all identical - red is fine unless you specifically built a multi-channel image.

The outputs

IMAGE (the upscaled mask as a visual image) and MASK (the same thing back as a mask). Wire the MASK into an inpaint/denoise node, a composite, or a preview.

Installing it

Part of ComfyUI_AC_FUNV8Beta1 by Cc啊程 (Bilibili ComfyUI teacher; README is Chinese). ComfyUI Manager (search "AC_FUN") or:

cd ComfyUI/custom_nodes
git clone https://github.com/A719689614/ComfyUI_AC_FUNV8Beta1

Restart ComfyUI. No downloads.

Where people get burned

The aspect-ratio autoscale is the feature most people miss because the widgets default to 512×512 - set both nonzero and you'll just squash your mask into a square. Let one side be 0 to keep proportions. And don't reach for this node expecting detail restoration: upscaling a mask is pure geometry, it can't invent cleaner edges than the source had. If your mask is rough, clean it before scaling, not after.

Category🔯AC_FUNV8.0

Inputs (6)

NameTypeDefaultDescription
maskMASK
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
widthINT5120–5277
heightINT5120–5277
cropCOMBO2 options: disabled, center
channelCOMBO4 options: red, green, blue, alpha

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK