Nodes/comfyui-huyl2-nodes/Draw Mask On Image (Optional)
ComfyUI Node

Draw Mask On Image (Optional)

A mask preview that never breaks your graph

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
Draw Mask On Image (Optional)
  • image
  • mask
  • images
color0, 0, 0
devicecpu

This node burns a mask onto an image so you can actually see what it's covering, and the useful part is right there in the name: both the image and the mask are optional, so it can sit permanently inline in a pipeline that only sometimes has a mask to show, without erupting into errors on the runs that don't.

Why "Optional" is the actual feature

The node's own description is direct about this: "Image and mask are optional - if only image is provided, returns it unchanged." That's the whole design. Most mask-preview tooling assumes a mask is always present, which means you either bypass the node manually when it isn't, or restructure your graph around whether this particular run has a mask. This one degrades gracefully instead - leave it wired in permanently, and it just passes the image through untouched on runs where there's nothing to draw.

How it works

It's an alpha blend: wherever the mask says "on," it overlays a color at whatever opacity you specify, letting you see both the mask's shape and how strong it is at a glance. The color is specified as free-form text, which the author's own tooltip explains clearly: "Color as RGB/RGBA values in range 0-255 or 0.0-1.0, separated by commas. Ex: 255, 0, 0, 128" - that example is semi-transparent red.

Inputs and outputs

  • color (STRING, required, default "0, 0, 0") - the overlay tint, comma-separated. Add a fourth value for alpha/transparency.
  • image (IMAGE, optional) and mask (MASK, optional) - both optional; the node handles the case where either is missing.
  • device (enum: cpu / gpu, default cpu) - where the blend computation runs, per its own tooltip.
  • Output: images (IMAGE) - the blended preview. Wire it into PreviewImage or SaveImage to actually look at it.

Installing it

No models, no extra dependencies mentioned in the README. Try ComfyUI Manager first (search the repo name), but this is a small personal pack and may not be indexed - the manual path is the reliable one:

cd ComfyUI/custom_nodes
git clone https://github.com/huyl3-cpu/comfyui-sortlist.git

Restart ComfyUI afterward.

Common issues and troubleshooting

No visible overlay usually means a malformed color string. There's no color picker or dropdown here - just free text with no format validation described. A stray space, or mixing the 0–255 range with the 0.0–1.0 range in the same string, is the likely culprit if nothing shows up.

This is a debug/preview node, not a compositing one. It lives in the "masking" category, but its only output is a tinted visualization - there's no modified mask output and no true composite. Don't wire its output into your sampler expecting anything downstream to be affected beyond the color overlay itself.

device defaults to cpu and there's no auto-detection. If you're running this across a lot of frames and it's slow, check whether you actually need gpu - but know that switching it is a plain dropdown choice, not something the node verifies against your hardware, so it won't fall back gracefully if a GPU isn't actually available to it.

CategoryHuyL3/masking

Inputs (4)

NameTypeDefaultDescription
colorSTRING0, 0, 0Color as RGB/RGBA values in range 0-255 or 0.0-1.0, separated by commas. Ex: 255, 0, 0, 128
imageoptIMAGE
maskoptMASK
deviceoptCOMBOcpuDevice to use for processing

Outputs (1)

NameTypeDescription
imagesIMAGE