ComfyUI Node

DP Extract Mask

Pull a mask out of an image in one node

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP Extract Mask
  • image
  • image
  • mask

You've got an image with transparency - a cutout PNG, a background-removed subject, a logo on a clear background - and the next node wants a MASK, not an image. This node bridges that gap: feed it the image, get back both the image and a mask derived from it. It's the small, boring, load-bearing utility that makes cutouts usable in inpainting and compositing graphs.

It's an image utility in DesertPixelAi's Desert Pixel pack, and it's about as simple as a node gets.

How it works

One input, image (IMAGE). The node reads the image and produces two outputs: image (passed through) and mask (MASK) derived from it - typically from the alpha/transparency channel, turning "where the image is transparent vs opaque" into a proper mask ComfyUI's mask-aware nodes can use.

That mask is what feeds a Set Latent Noise Mask, an inpainting conditioning, a paste/composite node, or anywhere else that wants to know which region to operate on. The classic pipeline is: run a background remover (or load a PNG with alpha), pass it through Extract Mask, and now you have the subject and its silhouette as a mask in one move.

Why a dedicated node instead of Load Image's mask output? Load Image only gives you a mask for the file you loaded through it. When the alpha you care about was produced mid-graph - by a background remover, a composite, a generated cutout - there's no loader in the chain, and Extract Mask is how you get the mask out of that in-flight image without saving and re-loading it.

The input and outputs that matter

There's exactly one input and no settings, so there's nothing to tune - connect an image, take the mask. The image passthrough is there so you don't have to branch the original separately.

How to install it

ComfyUI Manager: search Desert Pixel, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes

Restart ComfyUI. No downloads. Under the DP category.

Common issues & troubleshooting

The mask comes out empty or all-white. This node works off the image's transparency. A flat RGB photo with no alpha channel has no transparency to extract, so there's nothing meaningful to turn into a mask - you get a solid mask covering everything. If you're starting from an ordinary photo and want to isolate a subject, you need an actual segmentation/background-removal step first (BiRefNet, RMBG, SAM-based nodes), then Extract Mask on the result.

The mask is inverted from what I wanted. Depending on your downstream node, "opaque = masked" may be the opposite of what it expects. If the wrong region gets processed, drop an Invert Mask node after this one.

Edges are rough. The mask follows the image's alpha exactly, hard edges and all. If you want a soft transition for compositing, add a mask-blur/grow-and-feather node after extraction rather than expecting this node to smooth it.

CategoryDP/image

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK