Nodes/was-node-suite-comfyui/Mask Rect Area (Advanced)
ComfyUI Node Runs on cloud

Mask Rect Area (Advanced)

A rectangular mask defined in exact pixels

By WASasquatch·Created 3 years ago·Updated a day ago· 1,839
Mask Rect Area (Advanced)
    • MASKS
    x0
    y0
    width256
    height256
    image_width512
    image_height512
    blur_radius0
    drawn_mask
    drawn_combineunion

    WAS's plain Mask Rect Area places a rectangle by percentage of the canvas - clever because it scales automatically to whatever resolution you're working at, but useless the moment you need to land a mask at an exact, known pixel location. Mask Rect Area (Advanced) is that other case. Per the README, it creates "a rectangular mask defined by pixels and image size" - you specify the rectangle in absolute pixel coordinates, tell it the canvas size to paint against, and it gives you a mask that lands exactly where you told it to, no percentage math involved.

    Why exact pixels beats percentages here

    Percentages are great when you're eyeballing "roughly the top-left quarter." They're the wrong tool the moment a rectangle's position comes from somewhere numeric - a bounding box returned by a detector node, coordinates you measured off a reference image, a fixed compositing slot you use over and over at a specific resolution. Converting those numbers into fractions of the canvas before feeding Mask Rect Area is an extra, error-prone step. The Advanced variant skips that entirely: feed it the pixel numbers you already have.

    How it works

    You define the rectangle's position and size in absolute pixels, and separately specify the image size the mask canvas should match. The node paints a white rectangle at those exact pixel coordinates on a black canvas sized to match, which is what a mask fundamentally is in ComfyUI - white means "act here," black means "leave alone." Because the canvas size is a separate, explicit input rather than something inferred, the resulting mask always matches your actual working resolution, provided you keep that value in sync with your real image.

    The inputs and outputs that matter

    The rectangle's position and dimensions in pixels, plus the image size to build the mask canvas against. The output is a MASK at that canvas size, with a white rectangle exactly where you specified. It wires into an inpainting sampler, a Set Latent Noise Mask, or anywhere else a MASK is expected - same as its percentage-based sibling, just with pixel-exact placement instead of a proportional one.

    Installing it

    ComfyUI Manager: search "WAS Node Suite," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/WASasquatch/was-node-suite-comfyui
    

    install requirements.txt against your ComfyUI Python, restart. Pure geometry, no model or heavy dependency.

    Common issues & troubleshooting

    Mask doesn't line up with the image. Check that the image size input actually matches your real working resolution - if it's stale or hardcoded from an earlier version of your graph, the rectangle's pixel coordinates will be correct relative to the wrong canvas, and the mask will visibly drift off-target once composited against the real image.

    Hard-edged seam after inpainting. Same as any rectangle mask: a razor-sharp rectangle border generates a visible line where the edit meets the original. Modidex's inpainting notes put typical mask feathering around 4–12 pixels, with too little producing hard seams and too much bleeding past the intended edit - run the output through Mask Gaussian Region before using it if you're compositing rather than just previewing.

    Which variant do I actually want? If you're placing a rectangle from a detector's bounding box, known fixed coordinates, or anything already expressed in pixels - this one. If you're eyeballing a rough proportional region that should scale with resolution, the plain Mask Rect Area is less fiddly.

    Whole pack won't import. WAS Node Suite has been unmaintained since the author marked it retired in December 2023; the recurring failure is the entire suite throwing "Import Failed" after a ComfyUI update from a pinned dependency clash. Reinstall requirements.txt against the correct, embedded Python interpreter and restart.

    CategoryWAS Suite/Image/Masking

    Inputs (9)

    NameTypeDefaultDescription
    xINT00–4096Left edge of the rectangle, in pixels from the left of the mask. 0 starts flush against the edge.
    yINT00–4096Top edge of the rectangle, in pixels from the top of the mask. 0 starts flush against the edge.
    widthINT2560–4096How wide the rectangle is, in pixels, measured rightwards from x. 0 produces nothing, and anything past image_width is cut off.
    heightINT2560–4096How tall the rectangle is, in pixels, measured downwards from y. 0 produces nothing, and anything past image_height is cut off.
    image_widthINT51264–4096Width of the mask itself, in pixels. Match it to the image the mask will be applied to, or the two will not line up.
    image_heightINT51264–4096Height of the mask itself, in pixels. Match it to the image the mask will be applied to, or the two will not line up.
    blur_radiusINT00–255Softens the rectangle's edges, in pixels. 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 mask of image_width by image_height, white inside the rectangle and black outside.