Nodes/KJNodes for ComfyUI/Draw Mask On Image
ComfyUI Node Runs on cloud

Draw Mask On Image

See your mask before you commit to it

By kijai·Created 3 years ago·Updated about 17 hours ago· 2,930
Draw Mask On Image
  • image
  • mask
  • images
color0, 0, 0
devicecpu

Masks are invisible until something breaks. You build a mask, feed it to an inpainting sampler, and only when the result is wrong do you realize the mask was covering the wrong thing. Draw Mask On Image fixes that by painting your mask onto the image as a colored overlay, so you can eyeball exactly what's selected before you spend a generation on it. Its description is plain: "Applies the provided masks to the input images with Alpha Blending support."

It's a debugging and visualization node first, and a compositing node second. Either way, the value is the same - turning an abstract grayscale mask into something you can actually look at, laid over the picture it belongs to.

How it works

You hand it an image and a mask, and it blends a solid color into the image everywhere the mask is active, using the mask's own values as the alpha. Where the mask is fully white you get full color; where it's a feathered gray edge you get a partial tint, which is genuinely useful - it means you can see your blur falloff, not just trust it. The output is an image, not a mask, so it's meant to be viewed (or saved), not fed back into a sampler as a selection.

The inputs that matter

  • image - the picture to overlay onto.
  • mask - the mask you want to visualize or burn in.
  • color (default "0, 0, 0") - the overlay color as an R, G, B string. Black is the default, but for seeing a mask you'll usually want something loud like 255, 0, 255 (magenta) that never occurs naturally in your image. Pick a color your picture doesn't already contain.

There's one optional input, device (cpu or gpu), controlling where the blend runs. CPU is the default and fine; switch to GPU only if you're processing a huge batch and want it off the CPU.

The single output is images - the composited result.

Where it wires in

Two honest uses. First, as a preview: tap your mask into this node and a preview/save node, run it, and confirm the mask lands where you think before you commit it to the inpaint. This is the one that saves you wasted generations. Second, as a light compositing tool: burn a colored region into an image on purpose - a tint, a marker, a highlight.

Pair it with Grow Mask With Blur and you get a clear picture of what your grow-and-feather actually did - the soft edge shows up as a gradient in the overlay, which is the fastest way to tell whether your blur_radius is right.

Installing it

Ships with kijai's KJNodes pack.

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r requirements.txt, and restart.

No downloads; it's plain image compositing.

Common issues

The one that trips people: the output is an image, not a mask. Don't wire it into a sampler's mask input expecting it to work - it's the picture with the overlay drawn on, not a selection. Keep using your original mask for the actual inpaint; use this node's output only for looking at.

Second, if your default black overlay is invisible against dark areas of the image, that's not a bug - it's your color choice. Set color to something garish so the mask reads clearly against whatever you're overlaying. The whole point is to see it, and black-on-shadow defeats that.

CategoryKJNodes/masking

Inputs (4)

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

Outputs (1)

NameTypeDescription
imagesIMAGE