Node / Gif Animation · guide
Chroma transparency & frame disposal
Current Apexify.js 6.0.0 documentation for Chroma transparency & frame disposal.
GIF transparency in this API is indexed-color chroma transparency: the encoder selects one palette color as transparent for a frame. It is not per-pixel alpha in the encoded GIF.
transparentColor
Global: GIFOptions.transparentColor
Per frame: GIFInputFrame.transparentColor / GIFEncodedFrame.transparentColor
Accepted forms:
#RRGGBBRRGGBB0xRRGGBB#RRGGBBAA/RRGGBBAA(the encoder uses the RGB portion)- a 24-bit integer from
0x000000through0xFFFFFF nullto explicitly disable chroma transparency
Invalid strings, negative numbers, non-integers, and numeric values above 0xFFFFFF are rejected before encoding.
Precedence
For every frame:
Because null is distinct from undefined, a frame can explicitly turn off a global transparent color:
Disposal (GIFDisposalMethod)
Supported codes are:
| Code | GIF meaning |
|---|---|
| 0 | No disposal specified |
| 1 | Do not dispose; leave the frame in place |
| 2 | Restore the frame area to background |
| 3 | Restore to the previous composited state |
Per-frame dispose overrides GIFOptions.defaultDispose.
When neither is supplied, Apexify resets the encoder disposal mode deterministically for each frame:
- 2 when no transparent color is active
- 0 when chroma transparency is active
This reset matters because encoder settings are stateful. A frame-local disposal/transparency override does not silently leak into later frames.
Quantization caveat
The requested transparent RGB value is matched against the quantized GIF palette. Anti-aliased edges may contain neighboring colors and therefore remain partially visible. For chroma-key workflows, use hard edges or prepare the source frames accordingly.