Nodes/ComfyUI_Swwan/RGBA Multi Save (Swwan)
ComfyUI Node

RGBA Multi Save (Swwan)

Saving transparent PNGs without the white fringes

By aining2022·Created 9 months ago·Updated 10 days ago· 33
RGBA Multi Save (Swwan)
  • image
  • alpha
    has_alpha
    file_formatpng
    alpha_modeauto
    filename_prefixRGBA
    epsilon0.0010
    background_red1.00
    background_green1.00
    background_blue1.00
    jpeg_quality95
    webp_quality90
    webp_losslessfalse
    png_compress_level4

    If you've ever run a transparent PNG through a ComfyUI image node and gotten a white or black halo around the edges, you've hit the problem this whole RGBA family exists to solve. ComfyUI's IMAGE tensor doesn't carry alpha - most nodes are RGB-only - so Load Image converts transparency into an inverted mask, and by the time you've resized, blurred or composited, the alpha is either gone or the edges are fringed.

    RGBA Multi Save is the final-output node of that family. It takes a premultiplied image plus its real alpha, and writes a JPEG, PNG or WebP - keeping transparency when you want it, flattening to RGB when you don't. The name undersells it a bit: it quietly includes the "safe unpremultiply" logic internally, so it can replace a whole sub-graph of post-processing.

    What it needs

    To use it you first pass the image through the pack's RGBA Safe Pre node, which does two things: converts Load Image's inverted mask into a real alpha, and premultiplies the RGB so it survives RGB-only processing without dark edges. It hands you three outputs you feed straight into this node:

    • image - the processed (still premultiplied) image
    • alpha - the real alpha from Pre
    • has_alpha - a boolean saying whether the source actually had transparency

    Then you pick file_format (jpeg/png/webp), alpha_mode, and a filename_prefix. The optional group is where the tuning lives: epsilon (the lower alpha clamp that prevents divide-by-zero and blown edges during unpremultiply - keep 0.001), background color for flattening (defaults to white, which is why flattened PNGs come out with a white backing), and per-format quality/compression settings.

    How alpha_mode behaves

    | format | auto | keep | flatten | |---|---|---|---| | jpeg | flattened RGB | flattened RGB | flattened RGB | | png | keeps alpha if has_alpha | keeps alpha if has_alpha | flattened RGB | | webp | keeps alpha if has_alpha | keeps alpha if has_alpha | flattened RGB |

    auto is the right default for almost everything - it's the "do the sensible thing" switch. keep is for when you explicitly want transparent output and want to be sure. flatten forces a normal RGB file (thumbnails, social posts, training-set JPEGs), and because it skips the unpremultiply step entirely it's also the fastest path.

    Installing it

    It ships in ComfyUI_Swwan, which bundles the RGBA Safe Pre/Post/Save/Multi Save set plus a pile of other migrated nodes. Install via Manager (search "ComfyUI_Swwan") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aining2022/ComfyUI_Swwan
    pip install -r ComfyUI_Swwan/requirements.txt
    

    Where people get burned

    The classic mistake is feeding this node raw Load Image output - it needs Pre's alpha and has_alpha, not just the image. If you wire it without those, alpha handling silently degrades. Also remember the multi-save is a final node: it has no image output, so if you need corrected RGB and alpha to continue into more processing, put RGBA Safe Post in the middle and use this only at the end. And if you're still seeing fringe after saving: check that the intermediate nodes actually passed the premultiplied RGB through unchanged - anything that rescales color will wreck the premultiply relationship, which is exactly the "divide-by-zero and overbright edges" case epsilon was built to soften.

    CategorySwwan/RGBA

    Inputs (14)

    NameTypeDefaultDescription
    imageIMAGEProcessed image. If it comes from RGBA Safe Pre, it is usually still premultiplied.
    alphaMASKAlpha from RGBA Safe Pre. It will be resized automatically to the current image size.
    has_alphaBOOLEANBoolean flag from RGBA Safe Pre. Used by auto mode to decide whether alpha should be kept.
    file_formatCOMBOpngOutput file format. JPEG never keeps alpha. PNG and WebP can keep alpha.
    alpha_modeCOMBOautoauto: keep alpha only for PNG/WebP when has_alpha is true. keep: force alpha-capable save. flatten: composite over background color and save RGB only.
    filename_prefixSTRINGRGBAFilename prefix for saved files.
    epsilonoptFLOAT0.00100.000001–0.1Only used when alpha is kept. Prevents divide-by-zero and overbright edges during unpremultiply.
    background_redoptFLOAT1.000–1Background red channel used when flattening alpha to RGB.
    background_greenoptFLOAT1.000–1Background green channel used when flattening alpha to RGB.
    background_blueoptFLOAT1.000–1Background blue channel used when flattening alpha to RGB.
    jpeg_qualityoptINT951–100JPEG encoder quality. Higher values keep more detail and larger files.
    webp_qualityoptINT901–100WebP quality used in lossy mode.
    webp_losslessoptBOOLEANfalseEnable lossless WebP encoding. Usually larger but preserves pixels better.
    png_compress_leveloptINT40–9PNG compression level. Higher values reduce size but may save slower.

    Outputs (0)

    No outputs