Load Image as Mask with Switch
A mask loader you can toggle off in place
- mask
- enabled
The mask-loading counterpart to LoadImageWithSwitch: stock LoadImageMask plus an enabled toggle. Same pattern, different job - this one loads an image file and extracts one channel from it as a MASK, and when disabled, it doesn't load anything at all.
What it does
image- the standard file picker, from your ComfyUI input folder.channel- which channel of the source image becomes the mask:red,green,blue, oralpha.alphais the common choice when your source file actually has real transparency baked in; the RGB channels matter when your "mask" is a plain flat-color PNG someone painted by hand - a common way people export a rough mask from an image editor that doesn't support alpha channels directly.enabled(optional, defaulttrue) - when off, per the author's description, it will not load the image into a mask.
Outputs: mask (MASK) and enabled (BOOLEAN), the toggle state forwarded as its own output.
Why forward enabled as an output
Same reasoning as its LoadImageWithSwitch sibling: passing the boolean through lets you wire one checkbox into multiple downstream switch-aware nodes at once - say, disabling this mask loader and simultaneously disabling a compositor further down the graph that depends on it - instead of duplicating and manually syncing the same toggle in several places. It's a small design choice, but it's consistent across every *WithSwitch node in this pack, which suggests it's a deliberate pattern rather than a one-off.
It's the node to reach for whenever a mask source is conditional - a hand-painted mask you only want applied on certain runs of a shared workflow, for instance - rather than something you'd use for a mask that's always present. If the mask is always needed, the stock LoadImageMask node is simpler and does the same core job without the extra field to think about.
Installing it
ComfyUI Manager: search "ComfyUI-utils-nodes." Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes
Restart ComfyUI. No dependencies beyond core ComfyUI.
What to watch for
Two things. First, when enabled is off, mask isn't a valid output - treat this node as one link that has to be handled downstream, not something safe to feed directly into a compositor expecting a real mask every run. Second, and more commonly the actual bug people hit: picking the wrong channel. If your mask comes out either fully black or fully white - effectively covering nothing or everything - the source image very likely doesn't have meaningful data in the channel you picked. Check whether your source file actually has an alpha channel before defaulting to alpha; a flattened PNG exported without transparency will give you a useless, uniform mask on that channel every time.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | 1 options: example.png | |
| channel | COMBO | 4 options: red, green, blue, alpha | |
| enabledopt | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| enabled | BOOLEAN | — |