PngRectangles to Mask
One clean rectangular mask, with overlap
- PngRectangles
- mask
Where the color-mask nodes work off flat colors, this one works off geometry. The Mira Create PNG Mask nodes also emit a PngRectangles list - the raw x/y/width/height boxes for every block in your layout, with the whole image's dimensions tacked on as the last entry. This node turns one of those rectangles into a single MASK, and it's the one Mira mask node with a genuinely useful trick: it can bleed a region into its neighbors.
You'd reach for this in a regional-prompting graph, the standard answer to attribute bleed - two characters in one image trading hair colors and outfits because a single prompt paints the whole canvas. Rectangles give you clean, predictable region boundaries (no color-matching step), which is nice when your layout is a straightforward grid or tiling.
How it works
The rectangle list is pure coordinates. This node takes the box at your Start_At_Index, paints it into a grayscale mask at the intensity you set, and optionally softens the edge. The interesting part is Overlap: instead of a hard cut at the region boundary, you can pull in the previous or next N rectangles so the mask spills into its neighbors. That deliberate overlap is a quiet fix for the classic regional problem where hard-masked regions come out looking collaged with visible seams - a bit of controlled bleed at the joins reads far more naturally.
The inputs that matter
- PngRectangles - the rectangle list from a Mira Create PNG Mask node. The geometry source.
- Start_At_Index - which rectangle to render, zero-based.
- Intenisity - mask strength, 0 to 1. Leave it at
1.0for a solid mask; lower it to let the region only partially assert its prompt. (Yes, the README spells it "Intenisity" - that's the actual input name.) - Blur - edge feather.
0is a hard edge; raise it to soften the boundary. - Overlap -
None,Previous, orNext. This is the headline feature: merge neighboring rectangles into the current mask so regions blend instead of butting up against each other. - Overlap_Count - how many neighbors to pull in when Overlap is on.
The output
A single MASK. Wire it into whatever regional conditioning node you're using for this region. Because it's one mask per node instance, you drop one of these per region and point each at a different Start_At_Index.
Installing it
Install the pack via ComfyUI Manager (Manager -> Custom Nodes Manager, search ComfyUI_Mira, Install, restart), or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_Mira.git
Restart. If loading errors, pip install -r requirements.txt inside the folder and restart. No model files.
Common issues
Remember the last rectangle in the list is the whole image's width and height, not a region. Point Start_At_Index at it by accident and you'll mask the entire canvas, which usually isn't what you meant.
If your regions look pasted-on with sharp seams, this is the node to fix it: nudge Blur up, and try Overlap set to Previous or Next with a small count so the joins blend. That mirrors the broader regional-prompting wisdom - hard masks held all the way through the sample are exactly what produce the seam-y, collaged look; softening and overlapping the boundaries is the cure.
If you want all the rectangles as masks at once rather than one at a time, that's the sibling node PngRectanglesToMaskList - same idea, ten outputs, minus the overlap controls. And as always with this pack: it's a small solo project (the author's better-known work is their WAI Character Select app), so the README's own example graph is your most reliable reference.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| PngRectangles | MIRA_MASKS_LIST | — | |
| Intenisity | FLOAT | 1.00–1 | — |
| Blur | FLOAT | 0.0 | — |
| Start_At_Index | INT | 0 | — |
| Overlap | COMBO | 3 options: None, Previous, Next | |
| Overlap_Count | INT | 1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |