Nodes/ComfyUI-YCNodes_Toolkit/Load Image Brush Mask
ComfyUI Node

Load Image Brush Mask

Paint a mask on the image itself — no mask editor needed

By yichengup·Created 10 months ago·Updated 4 months ago· 59
Load Image Brush Mask
    • image
    • mask
    • width
    • height
    brush_data
    brush_size80
    image_base64

    ComfyUI's built-in mask editor is, let's be honest, an experience. Load Image Brush Mask (ycimagebrushmask) skips it entirely: the image is embedded on the node face, and you paint the mask directly on it. Brush to add, erase to remove, adjust the size, wire the mask out. No separate editor window, no save-and-reload dance.

    It's part of ComfyUI-YCNodes_Toolkit, yichengup's pack of frontend-style nodes, and it's the natural companion to the pack's crop nodes: where Load Image Crop Expand hands you a crop and a mask marking the expansion area, this node hands you a hand-painted mask for the exact region you want regenerated.

    How it works

    Your image travels as base64 in the image_base64 widget (auto-filled when you upload). Your strokes serialize into brush_data in the format mode:size:opacity:x,y;x,y;..., with strokes separated by |. The backend parses that, then paints circles and interpolated line segments into a mask tensor - vectorized with numpy, so it stays quick even on large images. The erase mode zeroes the mask back out; everything else adds white (1.0).

    • brush_size - brush diameter, 1–200, default 80. This is the one you'll actually touch.
    • brush_data / image_base64 - both auto-managed by the UI; leave them alone.

    Outputs: image, mask, width, height. The mask is 1.0 where you painted - exactly what an inpaint node wants.

    The README's one big warning

    Quote-worthy because it's the actual gotcha: before you export or share a workflow that uses this node, clear the image out (recreate the node). The embedded base64 image will balloon the exported workflow JSON into something enormous. The node's JavaScript does cache images to keep them out of saved workflows, but the author's own advice is the safe path - rebuild the node, let the image get re-uploaded on load.

    Installing

    cd ComfyUI/custom_nodes
    git clone https://github.com/yichengup/ComfyUI-YCNodes_Toolkit
    

    Restart (or install via ComfyUI Manager, searching "ComfyUI-YCNodes_Toolkit"). Dependencies are just numpy and Pillow - no models. Feed the outputs into any inpainting node and you've got a local, zero-round-trip inpainting setup.

    CategoryYCNode/utils

    Inputs (3)

    NameTypeDefaultDescription
    brush_dataSTRING
    brush_sizeINT801–200
    image_base64STRING

    Outputs (4)

    NameTypeDescription
    imageIMAGE
    maskMASK
    widthINT
    heightINT