ComfyUI Node

AdjustTransparency

Turn a mask into a real alpha channel

By 438443467·Created 2 years ago·Updated about a year ago· 27
AdjustTransparency
  • image
  • mask
  • IMAGE
invertfalse
complete_eliminationfalse
opacity100

A mask is just a grayscale map - until you need it to do something, like make part of an image transparent. AdjustTransparency takes an image and a mask and turns the mask into the image's alpha channel, with three switches you actually control: whether to invert the mask, whether to hard-kill the background, and how strong the opacity should be. This is the node you reach for when a cutout or an overlay needs to composite against anything other than black.

How it works

The image and mask both get converted to PIL. The mask is flattened to grayscale and (optionally) inverted. Then the behavior splits:

  • complete_elimination on - pixels outside the mask become fully transparent. It pastes the image onto a transparent RGBA canvas using the mask as the paste mask, so mask-covered areas survive and everything else is cleanly removed. This is the "real cutout" mode.
  • complete_elimination off - the mask is used directly as the alpha channel (putalpha), so grayscale mask values become semi-transparency. Softer edges, gradient masks, feathered selections.

Finally the opacity value (0–100, default 100, steps of 5) scales the whole alpha channel - 100 leaves it untouched, 50 halves every alpha value, 0 makes the image fully invisible.

Inputs and outputs

  • image - IMAGE.
  • mask - MASK (must be the same dimensions as the image, as with any mask-compositing node).
  • invert - BOOLEAN; flips the mask so you can quickly switch "keep the subject" / "keep the background."
  • complete_elimination - BOOLEAN; hard cutout vs. soft alpha.
  • opacity - FLOAT 0–100.

Output: IMAGE - an RGBA result with the alpha applied. Note ComfyUI's native preview shows a checkerboard-independent view, so check the actual alpha channel (or composite it onto something) rather than eyeballing the preview.

The practical pairing

This is the natural endpoint of a background-removal or segmentation workflow: get a mask from a removal node, then AdjustTransparency converts it into a usable cutout for compositing - drop it onto a new background, overlay it, or save it as a transparent PNG. If you've used a background-removal model like BRIA/RMBG or SAM to get a binary mask, complete_elimination gives you the clean cutout; if you want feathered edges for a soft blend, leave it off and tune opacity. Same pack caveat as everywhere else: removed in the April 2025 rewrite, so it only exists in the repo's older history.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/438443467/ComfyUI-GPT4V-Image-Captioner

Restart ComfyUI. No models, no downloads - pure PIL math.

CategorySanmi Simple Nodes/Simple NODE

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
maskMASK
invertBOOLEANfalse
complete_eliminationBOOLEANfalse
opacityFLOAT1000–100

Outputs (1)

NameTypeDescription
IMAGEIMAGE