Nodes/ComfyUI-GiftHelperSuite/Gift Icon Auto Restore & Export
ComfyUI Node

Gift Icon Auto Restore & Export

Turning a Klein render into a transparent gift icon

By lingziwyh·Created 5 months ago·Updated 5 days ago· 7
Gift Icon Auto Restore & Export
  • subject_rgba
  • subject_mask
  • original_black_image
  • preview_background
  • edge_guard_mask
  • preview
  • icon_1280_rgba
  • icon_168_rgba
fx_strength0.75
unmult_black_point0.105
fx_reach0.35
fx_edge_feather32
alpha_cutoff0.002
enable_edge_fadetrue
edge_guard_percent0.0
edge_feather_percent2.5
min_effect_visibility0.006
crop_padding0
output_padding8
target_size1280
thumbnail_size168
preview_scale1.04
preview_canvas_size1680
performance_modeauto

Your render is done, your icon isn't

You generated a gift icon on a pure black background - probably with Flux 2 Klein, which is where this workflow starts - and you chroma-keyed it into a transparent RGBA layer. Except now the glow is gone. Keyers treat black like any other backdrop, so all that soft light spill, the fireworks halo, the neon edge that made the effect look like money? Clipped to a hard alpha edge. Rebuilding it by hand is the kind of busywork that makes you want to drag the file into After Effects and never come back.

GiftIconAutoRestore is the end of that pipeline. It takes three things - the keyed subject, the keyer's alpha, and the original black-background render - and hands you a tight 1280 transparent icon, a 168-pixel thumbnail, and a preview, with the glow restored along the way. It's the last node in the Klein → Gift Chroma Master → export chain, the one that turns a "good enough for the feed" render into something you'd actually ship.

The name is honest: it's an Unmult (the AE trick that derives alpha from the brightest channel) wrapped in production logic.

How it actually works

Nothing here is a model. Under the hood it estimates the black floor and noise from a border sample of your original render, then converts max-channel intensity into one continuous AE-style alpha curve. A subject-shaped soft region (controlled by fx_reach and fx_edge_feather) limits how far that recovered alpha is allowed to roam, so distant specks don't get resurrected. The recovered glow layer is composited over your subject at fx_strength (default 0.75), and everything is cropped from the combined alpha - subject plus glow.

Two details matter once you ship icons for a living. Resizing goes through premultiplied alpha, which stops the black/grey fringing you get when you naively shrink a straight-alpha image. And the 168 thumbnail is derived from the tight source crop, not by downscaling the padded 1280 canvas, so its own long edge stays fitted instead of drifting.

There's also a safety feature you'll want on by default: enable_edge_fade softly fades anything touching the source canvas edge, so a close-up arm cropped by the frame can't become a straight, ugly boundary on your icon. The default only affects the outer 2.5% of the short side (~32 px at 1280) - the center is untouched.

The inputs that matter

Three required inputs, and they're a matched set:

  • subject_rgba - the Klein result packed by GiftChromaMasterPackRGBA, at original canvas size.
  • subject_mask - Gift Chroma Master's foreground alpha, where 1 = subject.
  • original_black_image - the raw black-background render, before keying. This is where the glow comes back from.

The one knob you'll actually touch is fx_strength - glow too faint, raise it; glow swallowing the subject, lower it. unmult_black_point (default 0.105, matching the old #380 chain) is the noise floor; raise it if faint haze expands the crop, lower it only if a genuinely useful dark effect disappears. Optionally, preview_background lets you swap the bundled 1680 guide for your own, and edge_guard_mask overrides the generated edge matte (1 = keep, 0 = fade).

Outputs are three IMAGEs: preview (composited over the checkerboard or your background), icon_1280_rgba, and icon_168_rgba. Wire the last two into a Save Image node set to PNG - these are images, not files, so nothing is written until you save it.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/lingziwyh/ComfyUI-GiftHelperSuite.git

Then restart ComfyUI. Or use ComfyUI Manager and search "GiftHelperSuite". There are no pip dependencies and no model downloads - it runs on the PyTorch ComfyUI already ships. The pack includes a production template (Gift_Icon_Auto_Restore_Production.json) with a placeholder source you swap for your own render, and on first launch it auto-copies its demo assets into ComfyUI/input (set GIFT_HELPER_SKIP_EXAMPLE_ASSETS=1 to opt out).

Where people get burned

  • Wrong upstream. This node doesn't do keying. Feed it the Chroma Master output or you'll either get errors (subject_mask is required) or icons with no real edge. It's the export step, not the pipeline.
  • Dropped alpha. Many stock ComfyUI nodes silently discard the fourth channel. If your icons come out looking flat, check every node between the keyer and this one.
  • Name collisions. If you have ComfyUI_Unmult_AE or the old standalone KeylightChromaKeyHub installed, the README warns about duplicate registrations - remove or disable them after migrating.
  • Glow looks weak. That's fx_strength, or a source with lifted blacks pushing unmult_black_point up. Tune, don't rebuild.

It's a niche tool for a niche pipeline - the gift-animation and livestream-effect world doesn't show up much in Western discussions. But if you're generating gift icons on black, this is the node that makes the whole chain feel finished.

CategoryGiftHelperSuite/Icon

Inputs (21)

NameTypeDefaultDescription
subject_rgbaIMAGEKlein + Gift Chroma Master Pack RGBA output at the original canvas size.
subject_maskMASKGift Chroma Master foreground alpha: 1=subject, 0=transparent.
original_black_imageIMAGEOriginal black-background subject + glow image before Klein.
fx_strengthFLOAT0.750–2Opacity of the automatically recovered glow/effect layer.
unmult_black_pointFLOAT0.1050–0.5AE Unmult black point. Default 0.105 matches the former #380 chain and keeps glow edges continuous without revealing black-floor noise.
fx_reachFLOAT0.350.05–1Maximum effect search distance relative to subject size.
fx_edge_featherINT320–256Softens the subject-shaped effect search region.
alpha_cutoffFLOAT0.0020–0.2Final alpha at or below this value is treated as invalid edge haze.
enable_edge_fadeBOOLEANtrueFade subject and effects before the source canvas edge so cropped arms/close-ups cannot leave a straight hard boundary.
edge_guard_percentFLOAT0.00–25Fully rejected border width as a percentage of the short canvas side. Default 0 keeps every non-edge pixel available.
edge_feather_percentFLOAT2.50.1–40Narrow soft transition at the outer canvas edge. Default 2.5% is about 32 px on a 1280 image, leaving the central 95% untouched.
min_effect_visibilityFLOAT0.0060–0.2Minimum premultiplied RGB contribution considered visible. The automatic border-noise estimate can raise this threshold.
crop_paddingINT00–256Optional pixels kept around the valid final-alpha bounds.
output_paddingINT80–512Transparent padding around the target-size ICON. The thumbnail padding is scaled proportionally from this value.
target_sizeINT128064–4096
thumbnail_sizeINT16816–1024
preview_scaleFLOAT1.040.05–4Preview ICON size relative to target_size before centering.
preview_canvas_sizeINT1680256–4096Size of the bundled square guide background when no custom background is connected.
performance_modeCOMBOautoAuto uses ComfyUI's CUDA device and returns outputs to the input device.
preview_backgroundoptIMAGEOptional background used only for the preview output.
edge_guard_maskoptMASKOptional custom safety matte: 1=keep, 0=fade. Overrides the generated rounded edge guard.

Outputs (3)

NameTypeDescription
previewIMAGEICON composited over preview_background; checkerboard when no background is connected.
icon_1280_rgbaIMAGETight-cropped RGBA, long side fitted to target_size, transparent short-side padding.
icon_168_rgbaIMAGEPremultiplied-alpha thumbnail derived from the standard ICON.