Nodes/ComfyUI_Mira/Create Mask With Canvas
ComfyUI Node

Create Mask With Canvas

A rectangle mask by the numbers

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
Create Mask With Canvas
    • mask
    C_Width512
    C_Height512
    X0
    Y0
    Width512
    Height512
    Intenisity1.0
    Blur0.0

    This node builds a rectangular mask by typing coordinates instead of painting one. You tell it how big the canvas is, where the rectangle goes, and how big it is, and out comes a MASK you can feed into regional conditioning, inpainting, or anything else that takes a mask. It's the "I know exactly where I want the box, let me just enter the numbers" alternative to a paint-based mask editor.

    Where it earns its place is regional prompting. Assigning different prompts to different areas of the canvas is the standing fix for two characters whose attributes bleed into each other - the girl on the left keeps her red hair, the one on the right keeps her blue - and every regional-conditioning setup needs masks that define those areas. A precisely-placed numeric rectangle is often cleaner than a hand-drawn one for that job, especially when you want a repeatable split you can tweak by editing a value.

    How it works

    You define a canvas of C_Width × C_Height, then place a rectangle inside it at top-left corner (X, Y) with size Width × Height. The node paints that rectangle into the mask at the intensity you set, optionally softening the edge. That's it - a solid geometric region, generated deterministically from the numbers. If you need more than one region, the author's tip is the right one: make several of these and combine them with a MaskComposite node set to operation: add.

    The inputs that matter

    • C_Width / C_Height - the canvas dimensions. Match these to your latent/image size so the mask lines up.
    • X / Y - the top-left corner of the rectangle on the canvas.
    • Width / Height - the size of the masked rectangle.
    • Intenisity - the mask's strength, 0 to 1 (yes, the label is misspelled in the node; it's the intensity). Leave it at 1.0 for a fully solid mask; lower it for a partial-strength region.
    • Blur - softens the mask edge. 0 gives a hard rectangle; raise it for a feathered edge, which is what you usually want for regional conditioning so the seam between regions isn't a visible hard line.

    Output is a single mask.

    Where it fits

    Feed it into a "Conditioning (Set Mask)"-style node for regional prompting, or into an inpainting node as the area to repaint. The Blur input is the quiet hero for regional work: holding hard-edged masks through a whole sample is what produces that collaged look with visible seams between regions, so a little blur helps the areas blend. And if you're building a symmetric multi-character split, just make one of these per region and add them together.

    Install

    ComfyUI Manager → Custom Nodes Manager → search ComfyUI_Mira → Install → restart. Or clone: cd ComfyUI/custom_nodes && git clone https://github.com/mirabarukaso/ComfyUI_Mira.git, restart. On a load error, pip install -r requirements.txt in the pack folder. No model files needed.

    Common issues

    The most common mistake is a mismatch between C_Width/C_Height and your actual image or latent size - the mask then lands in the wrong place or the wrong scale. Keep the canvas dimensions equal to what you're masking. If your regions come out with hard seams, add Blur. If a mask seems to "do nothing," check Intenisity isn't down near 0. And if you need overlapping or nested regions, this node makes one rectangle at a time by design - compose several with MaskComposite rather than expecting one node to do a complex layout.

    CategoryMira/Mask

    Inputs (8)

    NameTypeDefaultDescription
    C_WidthINT5128–4096
    C_HeightINT5128–4096
    XINT00–4096
    YINT00–4096
    WidthINT5128–4096
    HeightINT5128–4096
    IntenisityFLOAT1.00–1
    BlurFLOAT0.0

    Outputs (1)

    NameTypeDescription
    maskMASK