Nodes/ComfyUI-Light-Tool/Light-Tool: Extract Transparent Image
ComfyUI Node

Light-Tool: Extract Transparent Image

Turn a mask into an actual cutout with real transparency

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Extract Transparent Image
  • image
  • mask
  • image
invertfalse

Light-Tool: ImageMaskApply is the bridge between "I have a mask" and "I have a cutout." It takes an image and a mask, and uses the mask as the alpha channel, producing a transparent PNG-style image of just your subject. This is the node people reach for after a background removal, a segmentation model, or an inpainting mask - anywhere you've separated subject from background as black-and-white and need it to become actual, usable transparency.

The display name says it best: "Extract Transparent Image."

How it works

The mechanism is almost embarrassingly direct. The node converts the image to RGB, converts the mask to grayscale, and uses that grayscale as the alpha channel:

  • White mask pixels → fully opaque subject
  • Black mask pixels → fully transparent background
  • Gray mask pixels → semi-transparent, which is exactly what gives you soft, feathered edges if your mask has them

There's an invert toggle for when your mask is stored the other way around (white background / black subject - a common convention in some mask generators). Flip it and everything inverts.

One real constraint: the mask must be the same pixel size as the image, and the node will throw a ValueError if it isn't. It's a strict check with a clear message, which beats the silent corruption you'd otherwise get.

Inputs and output

  • image - the IMAGE tensor of your subject.
  • mask - the IMAGE tensor to use as alpha. Note it takes an IMAGE, not ComfyUI's MASK type - so you'll often convert with a mask-to-image node first if your segmentation output is a true MASK.
  • invert - boolean, default off.

Output is one image tensor with the alpha channel applied, ready to feed a Save Image node (PNG to keep the transparency) or a compositing node.

Where it fits in a workflow

This is the natural companion to the pack's own nodes, and the whole transparency pipeline clicks together:

  1. Remove the background (BiRefNet, rembg, an inpainting mask) → you get a mask.
  2. ImageMaskApply turns that mask into a real alpha cutout.
  3. AddBackground flattens it onto a solid color, or you save the RGBA PNG directly.
  4. BoundingBoxCropping trims the transparent dead space around the subject.

Community workflows that use this pack tend to wire exactly this chain together - the pack even shows up in Reddit recommendations when people ask for mask-splitting and cutout tooling, alongside LayerStyle and Masquerade.

Gotchas

The IMAGE-not-MASK input trips up more people than anything else. ComfyUI's segmentation and masking nodes commonly output the MASK type; if you plug one straight in, ComfyUI will often auto-convert or complain. Convert to image first, or draw/load your mask as an image. The size-mismatch error is the other one - resize the mask to match, which the pack's resize nodes handle cleanly. And remember the output is RGBA: if your downstream step can't handle alpha, flatten with AddBackground before it.

Install is standard - ComfyUI Manager → search ComfyUI-Light-Tool, or clone and pip install -r requirements.txt from custom_nodes, then restart. No models, no downloads.

CategoryComfyUI-Light-Tool/image/compositing

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
maskIMAGE
invertBOOLEANfalse

Outputs (1)

NameTypeDescription
imageIMAGE