Save Transparent PNG (RGBA)
Finally, a ComfyUI node that saves a real transparent PNG
- image
- alpha
Here's a ComfyUI pain point you've probably hit: you generate a transparent image - via LayerDiffusion, a Qwen layer decomposition, a matting model - and when you save it, the background is suddenly black or white. ComfyUI's built-in SaveImage writes RGB and quietly throws away the alpha channel; the transparency never makes it to disk. SaveTransparentPNG from Doki21yy's tiny comfyui-ps-normal-layer-composite pack is the fix: it writes an actual RGBA PNG with real transparency.
That matters more than it sounds. Transparent sprites are the standard currency for game engines, visual-novel sprite sheets, stickers, overlays, and anything you composite later. Every background-removal workflow ends in a transparent PNG, and the KB's own advice notes that "not all ComfyUI workflows support RGBA pipeline throughout - some nodes silently drop the alpha channel." This node exists to catch that alpha before it's lost.
How it works
It's a plain PNG saver that treats alpha seriously. The node takes your IMAGE, optionally an alpha MASK, decides what the alpha is, stacks them into a 4-channel RGBA tensor, and writes it with PIL in mode="RGBA". Two details make it behave:
alpha_mode-auto_rgba_or_alpha_mask(default) uses the image's own 4th channel if it has one, otherwise treats a wiredalphaMASK as straight alpha (white = opaque).comfy_transparency_maskinverts the mask instead, for masks that follow ComfyUI's quirky "white = transparent" convention - likeLoadImage's mask output.- Metadata survives. Like core
SaveImage, it embeds the prompt and workflow into the PNG's text chunks, so dragging the saved file back onto the canvas reconstructs the graph. If you post these to hosts that strip metadata, that's on the host, not the node.
The inputs
image- whatever you want saved. If you're coming from the pack's siblingPhotoshopNormalLayerComposite, wire itsrgba_imageoutput here and you're done.alpha(optional MASK) - needed only when your image is RGB-only.filename_prefix- defaultComfyUI_transparent; files get a_00001_counter, and a slash in the prefix makes a subfolder, same as core.compress_level- 0 to 9, default 4. PNG compression; higher is smaller files but slower. 4 is a sane default, and the only time to touch it is batch runs where saving speed matters.
Install
Same pack, same one-liner - no dependencies beyond what ComfyUI already ships, no model downloads:
cd ComfyUI/custom_nodes
git clone https://github.com/Doki21yy/comfyui-ps-normal-layer-composite.git
Restart ComfyUI. Or search the pack title in ComfyUI Manager.
The traps
- Still no transparency? You wired an
alphamask from a mask-edit node (white = selected) but leftalpha_modeoncomfy_transparency_mask, which inverts it - everything opaque becomes clear. Flip the mode. - A flat gray/white rectangle means the node got no alpha at all: either the image had no 4th channel and you didn't wire
alpha, or the mask was all-ones. Check what's actually feedingimage. - The preview looks fine but the file doesn't. Some viewers composite transparency against checkerboard; if your preview tab flattens to white, that's the viewer, not the file. Load it in an editor that shows alpha.
One honest caveat: this is a brand-new, single-commit pack from an author with no track record yet, so verify the output on your own workflow before trusting it in a production batch. But the code is dead simple, the logic is right, and for a job ComfyUI core refuses to do, simple is exactly what you want.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| filename_prefix | STRING | ComfyUI_transparent | — |
| alpha_mode | COMBO | auto_rgba_or_alpha_mask | 2 options: auto_rgba_or_alpha_mask, comfy_transparency_mask |
| compress_level | INT | 40–9 | — |
| alphaopt | MASK | — |
Outputs (0)
No outputs