GR Mask
Draw a shaped mask by position, not by hand
- MASK
A procedural mask generator: instead of painting a mask by hand or feeding one in from an image, you describe where you want it and what shape it should be, and this node draws it for you. Good for anything that needs a repeatable, parametrized mask - vignettes, fixed inpaint regions you want to reuse across a batch, or quick test masks when you're debugging a masking pipeline and don't want to open an image editor.
How it works
You set a canvas size (width/height), then describe the mask itself: its own size (mask_width/mask_height), where it sits vertically and horizontally (mask_position_v - bottom/middle/top, mask_position_h - left/center/right), a fine offset on top of that (offset_x/offset_y), and a shape (circle, square, rectangle, or oval). randomize scrambles the placement instead of using the fixed position/offset you set, and exclude_borders keeps the shape from touching the edge of the canvas - useful when a mask right at the image boundary would produce a visible seam.
The num_masks / min_dist / border_margin trio (all optional) push this from "one shape" to "several shapes scattered across the canvas" - set num_masks above 1 and the node places that many, keeping them at least min_dist apart so they don't overlap, and respecting border_margin as a buffer from the edges.
The inputs and outputs that matter
width/height- the canvas the mask is drawn on. Match your actual image dimensions.mask_width/mask_height- the size of the shape itself.mask_position_v/mask_position_h- coarse placement (nine effective positions from combining the two).mask_shape-circle,square,rectangle, oroval.randomize- ignore the position settings and place the shape randomly instead.num_masks(optional, default1) - go from one shape to a scattered field of them, withmin_distcontrolling spacing andborder_marginkeeping them off the edges.MASK(output) - feed straight into an inpaint node, a composite node, or anywhere else that takes a mask.
How to install it
Via ComfyUI Manager: search "GraftingRayman", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/GraftingRayman/ComfyUI_GraftingRayman
then restart. This pack shares one dependency across every node, this one included - OpenAI's CLIP package, separate from ComfyUI's own:
# portable build
.\python_embeded\python.exe -m pip install git+https://github.com/openai/CLIP.git
# system python
pip install git+https://github.com/openai/CLIP.git
Common issues & troubleshooting
Node missing from search. Check the CLIP install above - it's a pack-wide requirement, not specific to masking.
Mask doesn't line up with your image. width/height here have to match the actual image you're masking, not just be "big enough." A mismatch between this node's canvas size and your image's real dimensions will misalign the mask when you composite or inpaint with it.
Multiple masks overlapping when you didn't want them to. Raise min_dist - the default spacing might be tighter than you expect once num_masks climbs past two or three on a small canvas.
Shape gets clipped at the edge. Turn on exclude_borders, or increase border_margin if you're already using multi-mask mode - both exist specifically to stop a shape from running off the canvas edge.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| height | INT | 11–4000 | — |
| width | INT | 11–4000 | — |
| mask_width | INT | 11–4000 | — |
| mask_height | INT | 11–4000 | — |
| mask_position_v | COMBO | 3 options: bottom, middle, top | |
| mask_position_h | COMBO | 3 options: left, center, right | |
| offset_x | INT | -1024–1024 | — |
| offset_y | INT | -1024–1024 | — |
| mask_shape | COMBO | 4 options: circle, square, rectangle, oval | |
| randomize | BOOLEAN | — | |
| exclude_borders | BOOLEAN | — | |
| num_masksopt | INT | 11–100 | — |
| min_distopt | INT | 00–1000 | — |
| border_marginopt | INT | 00–1000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |