Gift Icon Auto Restore & Export
Turning a Klein render into a transparent gift icon
- subject_rgba
- subject_mask
- original_black_image
- preview_background
- edge_guard_mask
- preview
- icon_1280_rgba
- icon_168_rgba
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 byGiftChromaMasterPackRGBA, 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_AEor the old standaloneKeylightChromaKeyHubinstalled, 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 pushingunmult_black_pointup. 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.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| subject_rgba | IMAGE | Klein + Gift Chroma Master Pack RGBA output at the original canvas size. | |
| subject_mask | MASK | Gift Chroma Master foreground alpha: 1=subject, 0=transparent. | |
| original_black_image | IMAGE | Original black-background subject + glow image before Klein. | |
| fx_strength | FLOAT | 0.750–2 | Opacity of the automatically recovered glow/effect layer. |
| unmult_black_point | FLOAT | 0.1050–0.5 | AE Unmult black point. Default 0.105 matches the former #380 chain and keeps glow edges continuous without revealing black-floor noise. |
| fx_reach | FLOAT | 0.350.05–1 | Maximum effect search distance relative to subject size. |
| fx_edge_feather | INT | 320–256 | Softens the subject-shaped effect search region. |
| alpha_cutoff | FLOAT | 0.0020–0.2 | Final alpha at or below this value is treated as invalid edge haze. |
| enable_edge_fade | BOOLEAN | true | Fade subject and effects before the source canvas edge so cropped arms/close-ups cannot leave a straight hard boundary. |
| edge_guard_percent | FLOAT | 0.00–25 | Fully rejected border width as a percentage of the short canvas side. Default 0 keeps every non-edge pixel available. |
| edge_feather_percent | FLOAT | 2.50.1–40 | Narrow 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_visibility | FLOAT | 0.0060–0.2 | Minimum premultiplied RGB contribution considered visible. The automatic border-noise estimate can raise this threshold. |
| crop_padding | INT | 00–256 | Optional pixels kept around the valid final-alpha bounds. |
| output_padding | INT | 80–512 | Transparent padding around the target-size ICON. The thumbnail padding is scaled proportionally from this value. |
| target_size | INT | 128064–4096 | — |
| thumbnail_size | INT | 16816–1024 | — |
| preview_scale | FLOAT | 1.040.05–4 | Preview ICON size relative to target_size before centering. |
| preview_canvas_size | INT | 1680256–4096 | Size of the bundled square guide background when no custom background is connected. |
| performance_mode | COMBO | auto | Auto uses ComfyUI's CUDA device and returns outputs to the input device. |
| preview_backgroundopt | IMAGE | Optional background used only for the preview output. | |
| edge_guard_maskopt | MASK | Optional custom safety matte: 1=keep, 0=fade. Overrides the generated rounded edge guard. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | ICON composited over preview_background; checkerboard when no background is connected. |
| icon_1280_rgba | IMAGE | Tight-cropped RGBA, long side fitted to target_size, transparent short-side padding. |
| icon_168_rgba | IMAGE | Premultiplied-alpha thumbnail derived from the standard ICON. |