Image to Mask (With Alpha) 👻
Any Image Into a Mask, With a Brightness Knob
- image
- MASK
The quick way to get a mask out of an image's brightness
Masks are the currency of compositing, inpainting and conditioning - and a lot of the time you don't need a fancy segmentation model, you just need a mask that says "bright parts are kept, dark parts aren't." Image to Mask (With Alpha) does exactly that: it converts an image to grayscale and hands you the result as a MASK, with a slider to control how strong the conversion is.
Where it earns its keep: generating a light/shadow map from a render, making a soft region mask from a rough black-and-white doodle, or turning a luminance map into a mask for a blending node. When you want a precise subject mask, go use a segmentation approach - this is a blunt instrument, but for brightness-based masking it's the right one.
How it works
The mechanism is three lines of classic image math. It converts the image to grayscale using the standard luminance weights (0.299 × red + 0.587 × green + 0.114 × blue), multiplies every pixel by the alpha value, clamps the result to the 0–1 range, and returns it as a MASK. Handles 1, 3 or 4 channel images; anything else raises an error.
Here's the honest caveat about the name: "With Alpha" is a little misleading. The alpha input isn't read from an alpha channel - it's a global brightness multiplier. Crank it to 0 and everything goes black; leave it at 1 and the mask is a straight luminance map. A bright image gives a near-white mask, a dark one gives a near-black mask. It's a knob, not an alpha-channel reader.
The inputs that matter
Only two, and one of them you'll rarely touch:
- image (IMAGE) - the image to convert.
- alpha (FLOAT slider, default 1.0, range 0–1, step 0.01) - the brightness multiplier. Default is fine for most uses; lower it to push an overall bright image toward a usable mask.
Output: MASK, ready to wire into anything that consumes a mask.
Installing it
Ships in the ComfyUI-Minitools pack, a small personal toolkit from lepi ai - seven nodes under the "MiniTools" category (ghost 👻 in the names). Pure local math, no models, no keys.
cd ComfyUI/custom_nodes
git clone https://github.com/lepiai/ComfyUI-Minitools
then restart ComfyUI, or ComfyUI Manager → search "ComfyUI-Minitools" → Install → Restart.
Pack-wide gotcha, same as its siblings: the pack imports its LLM node at startup and that module needs openai. If it's missing, the whole pack fails to load and this node disappears too. Manager installs the pinned requirements automatically; if you cloned manually, pip install -r requirements.txt in ComfyUI's environment first. And one small behavior note: it processes the first frame of a batch, so feed it a single image unless you've batched deliberately.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| alpha | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |