Checking Masks

MaskPreview Node

maskpreview.json

This is the mask version of the Preview Image node.

Convert Mask to Image Node

convert_mask_to_image.json

Converts a mask into a black-and-white Image.


Creating Masks

Load Image (as Mask) Node

load_image_as_mask.json

Loads an image file directly as mask data.

  • channel:
    • red/green/blue: For a black-and-white image, any of these works.
    • alpha: Choose this to use the transparent areas of a transparent PNG as the mask.

Convert Image to Mask Node

convert_image_to_mask.json

Converts an IMAGE (RGB image) in the workflow to a MASK.

Think of it as the Load Image (as Mask) node split into its parts.

🪢 Color To Mask Node

color_to_mask.json

Converts a specific color in an image (such as a green screen) into a mask. In other words, chroma keying.

There is a core node with the same kind of function, ImageColorToMask, but you can't adjust its threshold, which makes it awkward to use, so I use the following custom node instead.

Specify the target color in RGB, and use threshold (tolerance) to set how far the color can be off.

Create Solid Mask Node

create_solid_mask.json

Creates a rectangular mask of the specified size.

Use this when you need a fully filled (or empty) mask.

Mask Editor

A tool for painting parts of an image as a mask (black-and-white image) right inside ComfyUI.

  • How to launch: Select a Load Image node etc. → Click 🌔 (Open Mask Editor) in the Node Selection Toolbox.

Switch functions with the tabs on the left edge.

  • Draw Mask: Draw a mask with a brush.
  • Fill: Fills an area enclosed by a hand-drawn mask.
  • Auto Select: Automatically masks areas with colors similar to the spot you click.

When you're done, click Save in the header to apply it.

For details on how to use it, see Mask Editor.


Utilizing Depth Maps

🪢 Depth Map

depthmapasmask.json

A depth map is a black-and-white gradient image, which means you can use it directly as a mask.

Smartphone apps that let you blur a photo's background after the fact work in basically the same way.

For how to create depth maps, see ControlNet Preprocessor.


Editing Masks

Resize Image/Mask Node

This is covered in detail in Resize Image/Mask Node, so see that page.

resize_imagemask_match_size.json

Here, I'll only cover match size. When you resize an image, the image and mask sizes can end up out of sync, so they no longer line up.

With match size, you can resize the mask to match a reference image, so the two line up while keeping the shape (and positions) intact.

CropMask Node

cropmask.json

Crops the mask to the specified range.

GrowMask Node

growmask.json

Expands the edges of the mask. A negative value shrinks it instead.

🪢 Gaussian Blur Mask Node

gaussian_blur_mask.json

Blurs the mask. This matters for blending edges when compositing.

InvertMask Node

invertmask.json

Inverts the mask, swapping black and white.

ThresholdMask Node

thresholdmask.json

Converts a mask with intermediate values (gradients) into a binary (white or black) mask at the specified threshold.

🪢 Remap Mask Range Node

remap_mask_range.json

Adjusts how a gradient mask is applied. Combine it with the depth map from earlier, and you can shift which depth the effect focuses on, which gives some fun results.


Compositing Masks

MaskComposite Node

maskcomposite.json

Composites two masks in various modes (addition, subtraction, multiplication, etc.).


Samples