Pet / Chroma Key + Transparent GIF
Why Your AI Pet Loop Comes Out With a Green Halo (and How This Node Kills It)
- images
- checker_preview
- foreground_mask
- saved_gif
You rendered a cute four-second pet loop, you want it as a floating sticker with no background, and what you got is a furry animal outlined in radioactive green. Pet / Chroma Key + Transparent GIF exists to close that gap. It takes a frame batch - video decoded to IMAGE, or an image-to-video output - pulls the screen out of every frame, and writes an animated GIF with a real alpha channel plus a file path you can hand downstream.
Why key instead of segment
ComfyUI's default answer to "remove the background" is a matting model, and as of mid-2026 that mostly means BiRefNet, which is genuinely excellent on stills. Wrong tool here. It costs a model download and a per-frame forward pass on what might be a few hundred tiny frames - and run independently on every frame, the mask breathes. The hairline wobbles, the ears shift a pixel each frame, and on a loop that reads as flicker nobody can unsee.
Chroma keying skips the guesswork. You asked for #00FF00, so the node knows exactly what to delete - the video model already re-rendered the hair and fine detail that a segmentation mask would have to reconstruct, and the key just does arithmetic on it.
How it works
Each frame is compared to key_color (a six-digit hex string, #00FF00 by default) using an RMS distance across R, G and B. Pixels inside that distance are background; pixels further out are subject; between the two the node builds a smoothstep ramp so the matte has soft edges.
The interesting part is what happens before any of that: the node runs connected-component labelling and throws away every candidate pixel that isn't reachable from the frame border. A green patch in the middle of your pet - a green collar, a green eye, a green wash on the coat - survives. Only the background, which by definition touches the canvas edge, gets keyed. That single trick is why this behaves better than a naive per-pixel keyer on a photo of an animal.
Then despill. Green bounces, so edge pixels come back contaminated. The node pulls the green channel down toward the max of red and blue, hardest at the matte boundary - including a dilated band just inside the subject, because GIF alpha is one bit and the first fully opaque pixel is exactly where a green fringe would otherwise sit.
The inputs you'll actually touch
Nine inputs, and only a few need thought:
images- the frame batch. At least two frames are required or the node raisesAt least two video frames are required.similarity(0.16) andsmoothness(0.08) - the "how green counts as green" pair. Too low leaves a green rim; too high starts eating the pet where it meets the background. The README suggests 0.20 / 0.10, which is a good starting nudge for green-screen video output.alpha_threshold(96 of 255) - where the soft matte becomes a hard on/off decision. Raise it for crisper, thinner edges; lower it to keep more of the wispy fringe, at the cost of a green-tinted halo.close_loop(off by default) - replaces the last frame with a copy of the first, so the GIF doesn't pop when it wraps. Interior frames are untouched, so this is exact closure, not a crossfade. Turn it on for looping stickers.key_color,despill,fps,filename_prefix- the rest.fpsdefaults to 28, a strange number for a format that stores frame delays in hundredths of a second; if tempo matters, use 20, 25 or 30 so delays land on round values.
Outputs and wiring
checker_preview is an IMAGE batch composited over a 16-pixel checkerboard - your honest quality check for the cutout. foreground_mask is the soft matte, before thresholding, so treat it as diagnostics: a beautiful smooth mask can still produce a chunky GIF edge, because the binary step happens after it. saved_gif is a STRING with the absolute path of the file, under ComfyUI/output/<filename_prefix>/. The node is an output node, so it previews the animation when the queue runs. One catch: GIFs carry no PNG text chunks, so your workflow metadata doesn't come with the file.
Install
ComfyUI Manager → search Pet Companion (the pack publishes under the id guardskill), or:
cd ComfyUI/custom_nodes
git clone https://github.com/GuardSkill/ComfyUI-Pet-Companion-Nodes.git
Restart ComfyUI; the node lands under Pet Companion/Green Screen. Dependencies are light - numpy, opencv-python, Pillow - no model files, no ffmpeg, no PyAV. Writing GIFs through Pillow instead of shelling out to ffmpeg is deliberate: the node runs off the main thread, and forking ffmpeg after Numba/TBB initialization is a known way to hang a render.
Where people get burned
similarity has a narrow sweet spot on fur, where anti-aliased edge pixels are literally a mixture of pet and background - too low leaves a green rim, too high eats the animal. The GIF-specific problems are format bugs you can't tune away: transparency is one bit, so semi-transparent fur and motion blur become hard edges; the palette is 256 colors, so banding in soft areas is normal; and some viewers ignore GIF transparency entirely and show a black or white rectangle. Verify in the node's own checker preview before blaming the node.
Last one: if nothing is transparent at all, check that the background actually touches the frame border. A subject that fills the frame, or a green area floating in the middle, is invisible to an edge-connected keyer by design.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| filename_prefix | STRING | pet_companion/loop | — |
| fps | FLOAT | 28.001–120 | — |
| key_color | STRING | #00FF00 | — |
| similarity | FLOAT | 0.160.01–0.7 | — |
| smoothness | FLOAT | 0.0800.001–0.4 | — |
| despill | FLOAT | 0.900–1 | — |
| alpha_threshold | INT | 961–254 | — |
| close_loop | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| checker_preview | IMAGE | — |
| foreground_mask | MASK | — |
| saved_gif | STRING | — |