LayerMask: MaskInvert
Flip a mask, black to white and back
- mask
- mask
The simplest node in the pack, and one you'll drop into graphs constantly. It flips a mask: what was white becomes black, what was black becomes white. That's it. Mask what you don't want and invert to select what you do, or fix the endless "the mask came out backwards" situation without rewiring anything.
Every masking workflow eventually needs this. A background remover gives you a subject mask but your inpaint wants the background; a threshold node selects the shadows but you want the highlights. One inversion and you're pointed the right way. It's plumbing, but you can't build the house without it.
How it works
It computes 1.0 − mask per pixel - a straight tonal inversion. Fully-masked (white, 1.0) pixels become fully-unmasked (black, 0.0) and vice versa, and any partial/feathered values flip proportionally, so soft edges stay soft, just reversed.
The inputs and outputs that matter
There's exactly one input and one output, which is why this article is short:
mask(MASK) - the mask to flip.
Output: mask (MASK), inverted. Wire it wherever the un-inverted one was going.
How to install it
ComfyUI Manager: search ComfyUI Layer Style, install, restart. Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
Restart afterward. No dependencies of note, no models - it's arithmetic.
Common issues & troubleshooting
There is nothing to break in the node itself. If it's not showing up, that's the pack not loading - the IMPORT FAILED message for ComfyUI_LayerStyle in your startup console. Across this pack that's usually one of two things: a stale install from before it was split into ComfyUI_LayerStyle and ComfyUI_LayerStyle_Advanced (delete the folder and reinstall clean), or a broken dependency upstream in your Python environment - a bad transformers/tensorflow state is the common one - crashing the import. Reinstall via Manager and it comes back.
Worth knowing: ComfyUI core and half the node packs out there also have a mask-invert. This one is convenient if you're already living in LayerStyle, but if you're chasing an import failure and just need an invert right now, the built-in "InvertMask" will do the same job while you sort the pack out. Also remember many LayerStyle nodes carry their own invert_mask toggle - if you're only inverting to feed one of those, flip its toggle instead of adding a node.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |