Nodes/ComfyUI_Mira/Create Nested PNG Mask
ComfyUI Node

Create Nested PNG Mask

Centered nested regions for masking

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
Create Nested PNG Mask
    • PngImage
    • PngColorMasks
    • PngRectangles
    • Debug
    Width576
    Height1024
    X256
    Y256
    unlimit_topfalse
    unlimit_bottomfalse
    unlimit_leftfalse
    unlimit_rightfalse
    Layout1,1,1

    Create Tilling PNG Mask gives you a grid. This one gives you rings. Create Nested PNG Mask builds concentric rectangles around a center point you choose, and it's the tool you reach for when the thing you want to separate is in the middle of the frame - a subject with a background around it, or a set of nested regions closing in on a focal point - rather than side-by-side characters.

    It lives in the same Mask group of ComfyUI_Mira, mirabarukaso's personal regional-conditioning kit for anime/Illustrious work. The pack is niche (the author's character-select app has more community mileage than these nodes), so think of Mira as a purpose-built toolbox rather than a household name. The nested-mask idea started life, per the author, as a watermark-removal trick - masking the outer edges of an image - and grew into a general nested-region generator.

    How it works

    You give it a canvas size, a center point X, Y, and a Layout string of weights like 2,4,1. The node draws rectangles nested around that center, weighted by the layout, and paints them as a color-coded PNG. Unlike the tiling node, here ; is treated the same as , - nesting is one-dimensional, so there's no perpendicular cut to worry about.

    The four unlimit_* booleans are the interesting part. Flip unlimit_bottom and every mask extends all the way to the bottom of the image instead of staying a closed rectangle; same for top, left, right. Combine them and you get L-shapes, bands, and open regions - the README's own example is 2,4,1 with bottom and right unlimited, which turns tidy nested boxes into a corner-anchored layout. This is what makes the node flexible: you're not stuck with symmetric frames.

    Inputs and outputs that matter

    • X / Y - the shared center of every rectangle. Move this off-center and the whole nest shifts.
    • Layout - weights for each nested ring, e.g. 2,4,1.
    • unlimit_top / unlimit_bottom / unlimit_left / unlimit_right - open a side so masks run to that edge.
    • Width / Height - match your generation size.

    Outputs mirror the tiling node: PngImage is your visual preview, PngColorMasks and PngRectangles are the lists you pipe into the rest of the Mira mask chain (Create PNG Mask, Color Mask to HEX/INT RGB) to get real MASK tensors, and Debug is a string worth sending to a ShowText node.

    Installing it

    Via ComfyUI Manager: search ComfyUI_Mira in the Custom Nodes Manager, Install, restart. Or manually: cd ComfyUI/custom_nodes && git clone https://github.com/mirabarukaso/ComfyUI_Mira.git and restart. If loading throws an error, run pip install -r requirements.txt in the pack folder. No models to download for the mask nodes.

    Common issues

    The mask geometry is only half the job - you still need a regional-conditioning setup downstream to actually apply it, and region masking is fussy by nature. Masked-conditioning implementations handle overlapping and nesting regions poorly compared to a model with native box conditioning, so nested regions that bleed into each other are a known limitation of the technique, not a defect here. If the seams between rings look collaged, that's the classic regional-prompting artifact: end the masking early so composition forms before you blend back to base conditioning.

    Practical tips: send Debug to a ShowText node to confirm how your layout parsed, and remember that with all four unlimit_* off you get closed nested rectangles - start there, then open sides one at a time so you can see what each does. If you're doing edge/watermark work, the corners-open configuration is the whole point.

    CategoryMira/Mask

    Inputs (9)

    NameTypeDefaultDescription
    WidthINT576
    HeightINT1024
    XINT256
    YINT256
    unlimit_topBOOLEANfalse
    unlimit_bottomBOOLEANfalse
    unlimit_leftBOOLEANfalse
    unlimit_rightBOOLEANfalse
    LayoutSTRING1,1,1

    Outputs (4)

    NameTypeDescription
    PngImageIMAGE
    PngColorMasksMIRA_COLOR_LIST
    PngRectanglesMIRA_MASKS_LIST
    DebugSTRING