Nodes/yiu_comfy_nodes/🟦 Image To Zone Mask
ComfyUI Node

🟦 Image To Zone Mask

Draw a rounded-rectangle zone mask without touching a brush

By leizingyiu·Created about a year ago·Updated 3 months ago· 1
🟦 Image To Zone Mask
  • image
  • mask
  • help_text
x_pos50.0
y_pos50.0
x_scale50.0
y_scale50.0
lock_yscale_to_xscalefalse
radius20.0
feather_radius0.0
invertfalse

Sometimes you don't need a mask that hugs the subject. You need a rectangle - rounded, feathered, dead center or shoved to one edge - and you need it reproducible. That's the whole job of yiuImgToZoneMask: it reads your image's dimensions and generates a rounded-rectangle mask whose size, position, corner radius and feather are all percentages, so you can dial in a "zone" and reuse it across a batch.

Reach for it when you want a region mask without hand-painting. A common pattern in this pack: use it to define the placement zone - a rounded rectangle where the product should sit - and then pipe that mask into yiuFitItm2Msk's canvas_mask input. Flip invert on and it becomes an outside-white mask, which is exactly the shape an outpainting region wants.

How it works

Everything is percentage math against the input image's size. x_scale/y_scale set the mask's width/height as a percent of the image; x_pos/y_pos position it within the remaining space (so 50/50 centers it, 100 pushes it to the bottom-right corner). The corners are handled by a simple ramp: radius at 0 gives sharp corners, 50 gives a full capsule, and 50→100 blends the capsule into an ellipse. Feathering is a Gaussian blur whose radius maps feather_radius (0–100%) to half the mask's long side. If lock_yscale_to_xscale is on, y_scale is ignored and the height follows the width, keeping a square zone.

The image input is used for its size only - you don't feed it anything meaningful, just any image with the resolution you care about.

The inputs that matter

  • image - size reference only.
  • x_pos / y_pos (0–100), x_scale / y_scale (0–100) - position and size as percentages.
  • radius (0–100), feather_radius (0–100), invert - corner roundness, soft edge, and flip.

Output

Just mask, plus the pack's usual help_text string. The mask is grayscale - white where the zone is, black outside, soft shoulder if you feathered.

Installing it

Part of yiu_comfy_nodes by leizingyiu. ComfyUI Manager → search yiu_comfy_nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/leizingyiu/yiu_comfy_nodes

Restart after. No extra dependencies or downloads.

Where people get burned

  • The image input really is only for size. New users hook up a scene expecting the mask to be based on the subject. It's a canvas, not a detector.
  • Percent-position math. Because x_pos/y_pos place the mask in the leftover space, a 50% scale mask at x=0 sits flush left with its right edge at the image's center - not at the 0% mark you might expect. The tooltip explains it; trust the tooltip.
  • Invert is an outside-white mask. If you're outpaint-ing, that's what you want - the extension region is white. If your inpaint node treats white as "edit me," double-check which side is protected.
Categoryyiu_nodes

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
x_posFLOAT50.00–100
y_posFLOAT50.00–100
x_scaleFLOAT50.00–100
y_scaleFLOAT50.00–100
lock_yscale_to_xscaleBOOLEANfalse
radiusFLOAT20.00–100
feather_radiusFLOAT0.00–100
invertBOOLEANfalse

Outputs (2)

NameTypeDescription
maskMASK
help_textSTRING