Nodes/comfyui-ps-normal-layer-composite/Save Transparent PNG (RGBA)
ComfyUI Node

Save Transparent PNG (RGBA)

Finally, a ComfyUI node that saves a real transparent PNG

By Doki21yy·Created 3 months ago·Updated 3 months ago· 0
Save Transparent PNG (RGBA)
  • image
  • alpha
    filename_prefixComfyUI_transparent
    alpha_modeauto_rgba_or_alpha_mask
    compress_level4

    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 wired alpha MASK as straight alpha (white = opaque). comfy_transparency_mask inverts the mask instead, for masks that follow ComfyUI's quirky "white = transparent" convention - like LoadImage'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 sibling PhotoshopNormalLayerComposite, wire its rgba_image output here and you're done.
    • alpha (optional MASK) - needed only when your image is RGB-only.
    • filename_prefix - default ComfyUI_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 alpha mask from a mask-edit node (white = selected) but left alpha_mode on comfy_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 feeding image.
    • 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.

    Categoryimage/save

    Inputs (5)

    NameTypeDefaultDescription
    imageIMAGE
    filename_prefixSTRINGComfyUI_transparent
    alpha_modeCOMBOauto_rgba_or_alpha_mask2 options: auto_rgba_or_alpha_mask, comfy_transparency_mask
    compress_levelINT40–9
    alphaoptMASK

    Outputs (0)

    No outputs