load MASK from alpha channel
Turn an RGBA file's alpha channel into a mask
- mask
- exists
Basic data handling: PathLoadMaskFromAlpha ("load MASK from alpha channel") extracts a mask from the alpha channel of an image - no image output, just the mask, plus an exists flag. If your source of truth is a transparent PNG whose alpha is the selection, this is the leanest way to get that selection into the graph.
Here's the workflow that makes it click. You have cutouts with transparency - logos, stickers, product shots, subjects knocked out in Photoshop or any editor. Those files encode the region you care about in their alpha. Feed the file path here and the alpha becomes a mask you can pipe into inpainting, compositing, or any mask-using node - without loading the full image tensor you don't need. Where the pack's RGBA loader gives you image and mask, this one gives you just the mask; when that's all you want, it's one less wire cluttering the graph.
How it works
It opens the image with Pillow and pulls the alpha channel, converting it to a float tensor in the 0–1 range and inverting it: 1.0 - alpha. So fully transparent pixels become 1 (white), fully opaque become 0 (black). That matches ComfyUI's mask convention - white marks the region that gets erased, replaced, or inpainting attention - rather than the raw PNG convention where alpha is the opposite.
A couple of implementation notes:
- No alpha → blank mask. A plain RGB file has no alpha channel, so you get an all-zero (black) mask, not an error. The loader also handles palette-mode PNGs that carry a
transparencyentry by converting to RGBA first. - Missing file → empty 1×1 mask +
exists=False. Graceful, same as the pack's other loaders. Gate on the flag if a silent blank would be bad.
Inputs and outputs
- path (STRING, default
"") - the image file to read alpha from. - mask (MASK) - the alpha as a mask, white = transparent, in ComfyUI orientation.
- exists (BOOLEAN) -
Trueif the file loaded.
Installing it
Part of Basic data handling, no dependencies beyond what ComfyUI ships. 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.
Gotchas
The orientation question is the recurring one: the mask is inverted from the raw alpha by design, because ComfyUI masks treat white as "operate here." If your inpaint/composite comes out backwards, that's the first thing to check, and flipping it is one mask-invert node away. And don't expect this to recover a mask from a JPEG - JPEGs have no alpha channel, so you'll get a blank black mask every time. For anything with real transparency, though, it's a clean one-node extraction that slots straight into mask pipelines.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| exists | BOOLEAN | — |