ComfyUI Node Runs on cloud

Mask Rect Area

A rectangular mask defined by percentages, not pixels

By WASasquatch·Created 3 years ago·Updated 2 days ago· 1,839
Mask Rect Area
    • MASKS
    x0
    y0
    width50
    height50
    blur_radius0
    drawn_mask
    drawn_combineunion

    Sometimes you don't need a fancy segmentation model to make a mask - you just need to say "this rectangular chunk, right here." Mask Rect Area does exactly that. The WAS README describes it as creating "a rectangular mask defined by percentages," and that percentage part is the clever bit: instead of hardcoding pixel coordinates, you place the rectangle in relative terms, so the same node works whether your image is 512×512 or 1536×2048.

    It's the quick, deterministic way to get a mask when you already know where the region is - inpainting a fixed corner, protecting or targeting a band of the image, feeding a rough region to a downstream crop or composite. No model, no guessing, fully reproducible.

    How it works

    You define a rectangle by percentages of the image - where it starts and how big it is relative to the full width and height - and the node paints that rectangle white on a black canvas, which is what a mask is in ComfyUI: white is "act here," black is "leave alone." Because everything's expressed as a fraction of the image rather than absolute pixels, the mask scales with whatever you feed it. WAS also ships a Mask Rect Area (Advanced) variant that lets you define the rectangle in actual pixels plus an image size, for when you need exact pixel placement instead of proportions.

    The inputs and outputs that matter

    • The rectangle position and size, as percentages - where the box sits and how large it is, relative to the image.
    • A mask out - the white-rectangle-on-black mask, ready to wire into an inpainting sampler, a Set Latent Noise Mask, or any node that takes a MASK.

    I'm working from the README's "defined by percentages" description rather than a formal schema, so I'm not going to invent exact widget names for each edge of the rectangle - but the percentage-in, mask-out shape is the point, and it's what separates this from the Advanced pixel-based version.

    How to install it

    Part of the WAS Node Suite:

    • ComfyUI Manager: search was-node-suite-comfyui, install, restart.
    • Manually: cd ComfyUI/custom_nodes && git clone https://github.com/WASasquatch/was-node-suite-comfyui/, then pip install -r requirements.txt against your ComfyUI Python, and restart.

    Pure geometry - no model download, no heavy dependency.

    Common issues

    The classic hard-edge problem: a rectangle mask has razor-sharp borders, and if you inpaint straight through it you'll often see a visible seam where the generated region meets the original. Standard inpainting hygiene fixes it - feather or blur the mask edge before you use it (WAS has a Mask Gaussian Region node for exactly this), and match your denoise so the new content blends. A crisp rectangle is great for selection, rough for blending.

    The other thing: percentages are relative, so double-check your rectangle actually lands where you think on a non-square image. A box that looks centered on a square can sit off to one side on a tall portrait if you're thinking in pixels instead of fractions. If you need pixel-exact placement, reach for the Advanced variant instead.

    And the pack-wide caveat: WAS Node Suite has been retired since December 2023 - heavily used, unmaintained. If a ComfyUI update makes every WAS node disappear with an "Import Failed", that's suite-level dependency drift, not this node. Re-run requirements.txt against the correct Python environment (or the bundled install.bat) and restart.

    CategoryWAS Suite/Image/Masking

    Inputs (7)

    NameTypeDefaultDescription
    xINT00–100Left edge of the rectangle, as a percentage across the canvas. 0 is the far left, 50 is the centre line.
    yINT00–100Top edge of the rectangle, as a percentage down the canvas. 0 is the top, 50 is halfway down.
    widthINT500–100How wide the rectangle is, as a percentage of the canvas. 100 spans the full width, 50 covers half of it, 0 produces nothing. Anything running past the right edge is cut off.
    heightINT500–100How tall the rectangle is, as a percentage of the canvas. 100 spans the full height, 50 covers half of it, 0 produces nothing. Anything running past the bottom edge is cut off.
    blur_radiusINT00–255Softens the rectangle's edges, in pixels of the 512-pixel canvas. 0 keeps them hard; 32 gives a wide fade that also pulls the corners in. Large values are slow, because the blur window is twice this plus one across.
    drawn_maskoptSTRINGThe mask painted on the node, written by the interface and saved with the workflow. Empty means nothing was painted, and the node then produces the rectangle alone. Clear the field to remove the painting.
    drawn_combineoptCOMBOunionHow the painting joins the rectangle. union keeps whichever of the two is brighter at each pixel, subtract takes the painting away from the rectangle, intersect keeps whichever is darker, and off ignores the painting without deleting it. The painting is resized to the mask when the two differ.

    Outputs (1)

    NameTypeDescription
    MASKSMASKA 512x512 mask, white inside the rectangle and black outside. Scale it or let a downstream node resize it to match the image it is used with.