load MASK from greyscale/red
A mask from a greyscale file — or the red channel, if you prefer
- mask
- exists
Basic data handling: PathLoadMaskFromGreyscale ("load MASK from greyscale/red") turns a brightness-based image into a mask. Feed it a greyscale file - or an RGB image, in which case it uses the red channel - and you get a mask where the original intensity becomes mask coverage, plus an optional invert flip.
This is the node for masks that live as painted or rendered images rather than as alpha. Plenty of pipelines produce masks as standalone files: hand-painted mattes, depth-like greyscale maps, masks exported by other tools. Inpainting and compositing nodes want those as MASK tensors, and this loader converts the pixels directly - no separate channel to fish out, no manual thresholding. If the source is a true greyscale (mode L) it uses the intensity; if it's RGB or RGBA it takes the red channel (a common convention for storing masks as one channel); anything else gets converted to greyscale first.
How it works
The channel value (greyscale intensity or red) is normalized to 0–1 and then inverted by default: 1.0 - gray. So a white mask source - the typical "paint what you want to affect in white" convention - becomes a black mask, because ComfyUI's mask convention is the reverse: white marks the region that gets erased or regenerated. That's deliberate. And it's why the node ships an invert input: set it to True and you get the raw orientation back, for pipelines that expect it the other way.
Two behavior notes from the source:
- Missing or unreadable file → empty 1×1 mask +
exists=False. Graceful, standard for this pack's loaders. - No alpha/red to worry about here - if you need alpha-based masks, that's the sibling
PathLoadMaskFromAlpha. This node is strictly about brightness/red.
Inputs and outputs
- path (STRING, default
"") - the image file. - invert (BOOLEAN, default off) - flips the mask (
1.0 - mask) after extraction. - mask (MASK) - the result.
- exists (BOOLEAN) -
Trueif the file loaded.
Installing it
Part of Basic data handling, no extra dependencies. ComfyUI Manager → search "Basic data handling" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart after. No models, no pip.
Gotchas
Orientation, again, is the whole ballgame. The default output is inverted from what you see in the file because ComfyUI masks are white-to-operate - if your effect applies to the wrong half of the image, flip invert. And the red-channel rule will surprise you if you feed in a colorful RGB file expecting some kind of luminance: it's red only, not a proper grayscale conversion. For hand-painted mask workflows it's the natural fit, and the single invert toggle covers most of the "it's backwards" cases in one click.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| invertopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| exists | BOOLEAN | — |