If an existing ComfyUI MASK selects the wrong side of the boundary, connect it to InvertMask and use the node’s MASK output in place of the original mask downstream. The node reverses mask values, making previously masked and unmasked areas trade roles. First confirm that the problem is the mask’s direction: inversion will not fix a wrong source channel, missing alpha, or a mask that is misaligned with the image.
Decide whether inversion is the right fix
Name two areas before editing the graph: the area you want selected, and the area you want protected. Inspect the current MASK preview or values at both locations. In the simple case, the intended area is dark while the protected area is light, or the reverse of the convention required by the next node. That is a direction problem.
Do not add InvertMask just because the mask looks wrong. If the preview shows the wrong subject or a shifted boundary, investigate how the mask was made or aligned. If the mask came from an image channel, confirm the channel choice at its source. Choosing RGB, alpha, or another input is a different operation from reversing values. ComfyUI’s InvertMask documentation describes a MASK input and an inverted MASK output; it does not say that this node selects or repairs the channel used to create the input.
Insert the node in the existing path
- Locate the
MASKwire currently feeding the downstream node that uses the mask. Identify the intended selected area and the protected area in that same mask. - Add
InvertMaskto the graph. Connect the existing MASK wire to itsmaskinput. - Connect
InvertMask’smaskoutput to the downstream input that previously received the original MASK. Keep the original branch connected if other nodes still need the unaltered mask. - Inspect the mask after inversion, using the same preview method and the same two locations. Check that the regions exchange values and that the outline remains in the same place.
InvertMask accepts and returns data of type MASK. For visual inspection, ComfyUI’s MaskToImage documentation describes converting a MASK to an IMAGE. That conversion can help you view the mask; it is not the inversion step and does not by itself establish which area a downstream node treats as selected.
Compare the same two regions
The following is a hypothetical grayscale observation for a mask preview, not a measured ComfyUI result. Assume your subject is the area to select and the surrounding background is to protect. Record approximate values from the same interior points, away from the boundary.
| Checkpoint | Subject point | Background point | Boundary and alignment |
|---|---|---|---|
| Before inversion | 32, dark | 224, light | Subject outline is in the intended position |
| After inversion | 223, light | 31, dark | Same outline position; only region values trade |
The numbers illustrate the expected opposite relationship, not a guaranteed exact output value. A practical acceptance check is that the subject and background exchange roles in the preview while the mask’s dimensions, position, and grayscale transition at the edge remain unchanged. If you inspect only the subject, you could miss a connection error that also leaves the background selected.
If the result is still wrong
If both regions appear unchanged, verify that the downstream node is connected to InvertMask’s output, not still connected directly to the original MASK. If the wrong shape or location remains, inversion has not addressed the cause: inspect the mask-generating node, its input, and alignment with the image. If the center and background look right but the edge behaves unexpectedly, investigate the existing grayscale edge or any separate feathering operation. Inversion reverses values; it is not an edge-feathering control.
The documentation defines the node’s purpose and typed input/output, but does not specify a UI preview workflow, exact numeric output for every input, or downstream selection semantics. Judge those in the graph and the consuming node you actually use. Do not treat InvertMask as an alpha-extraction, channel-selection, alignment, or feathering operation.
Common questions
Does inversion make white the selected area?
It reverses the values in the input MASK. Whether a downstream operation interprets a particular value as selected depends on that operation; confirm the intended result in its context rather than assuming a universal convention.
Should I invert before or after creating the mask?
Connect InvertMask after the MASK you want to reverse and before the node that should receive the reversed version. If the input was made from the wrong channel, correct that source choice first.
Will it move or soften the boundary?
The documented operation is value inversion, not repositioning or feathering. Compare the same edge before and after. If its position or softness changed, inspect other graph operations or connections rather than attributing that change to inversion.
Sources and next step
This guide interprets public documentation and uses explicitly hypothetical acceptance examples, not application tests. Controls and availability can change; verify the cited manual against your installed version.
For work created in Imagild, carry the input requirements and acceptance checklist into the photo editor. The external software controls discussed above belong to their respective products.