2🐕Mask image exchange
Convert between a MASK and an IMAGE without extra nodes
- mask_input
- image_input
- output_image
- output_mask
ComfyUI treats MASK and IMAGE as different socket types even though a mask is, structurally, just a single-channel grayscale image - and that split trips people up constantly. You've got a mask from one node and the next one wants an image; you've got an image (or its alpha channel) and the next one wants a mask. Mask image exchange is a small converter node built to sit at exactly that seam.
How it works
Both inputs are optional: mask_input (MASK) and image_input (IMAGE). You feed it whichever one you actually have. It returns two outputs regardless - output_image and output_mask - so the conversion goes both directions through the same node: hand it a mask and get back an image representation of it (typically a grayscale visualization) alongside the mask itself; hand it an image and get back a mask derived from it alongside the image itself. Since both inputs are optional rather than required, the practical pattern is: connect only the one you have, and take whichever of the two outputs you actually need for the next node in your chain.
What to actually set
There's nothing to configure - connect one input, use one or both outputs. It's a pure type-bridge, not a processing step with settings.
Installing it
ComfyUI Manager: search "Comfyui-ergouzi-Nodes", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/11dogzi/Comfyui-ergouzi-Nodes.git
No models, no dependencies beyond what ComfyUI already ships with - this is a lightweight tensor reshape/repeat operation, not anything computationally heavy. As with the rest of the pack: this English repo is the frozen branch, with the author's active development happening in a separate Chinese-first sibling repo.
Common issues & troubleshooting
Only feeding one input and getting an unexpected result from the "other side." Since both inputs are optional, leaving one disconnected doesn't error - but whatever comes out of the output that corresponds to the input you didn't provide is derived rather than passed through untouched, so don't assume output_mask is identical to some mask you had elsewhere in the graph if you only ever fed in image_input. If you need a specific existing mask preserved exactly, wire it in directly rather than expecting this node to reconstruct it.
Mask-from-image conversion looks too coarse or too aggressive. A derived mask from a flat image (no alpha channel) is likely built from luminance or a similar simple rule, which won't match a hand-painted or model-generated mask's precision - this node is a convenience bridge for type mismatches, not a substitute for a proper segmentation or matting node when you need an accurate mask from scratch.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_inputopt | MASK | — | |
| image_inputopt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output_image | IMAGE | — |
| output_mask | MASK | — |