On this page
Overview
Encodes indexed frames into a bounded animated GIF using palette mapping and LZW.
- Artifact
GifEncoder.js· esm - Classification
public first party - Availability
Cross-host - Normalization
Normalized byte output and bounds.
Import and lifecycle
import * as module from '/arcane/modules/GifEncoder.js';
Holds indexed frames in memory; encode allocates and returns a GIF Blob without I/O.
Application-facing behavior: default GifEncoder, indexPixels(), lzw().
Protocol and host implementation
In-process only This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
default | default · class | class GifEncoder | — |
indexPixels | function | function indexPixels(data) | data |
lzw | function | function lzw(indices) | indices |
| Callable | Kind | Exact public signature | Parameter syntax |
|---|---|---|---|
indexPixels | exported-function | function indexPixels(data) | data |
lzw | exported-function | function lzw(indices) | indices |
| Member | Kind | Exact public declaration | Parameter syntax |
|---|---|---|---|
GifEncoder.constructor | constructor | constructor(width,height,{loop=0}={}) | width,height,{loop=0}={} |
GifEncoder.addFrame | method | addFrame(imageData,{delay=250}={}) | imageData,{delay=250}={} |
GifEncoder.encode | method | encode() | — |
Parameter meanings and results
GifEncoder(width, height, {loop}).addFrame(imageData, {delay}) returns the frame count, and encode() returns an image/gif Blob. indexPixels maps RGBA to the fixed palette, and lzw returns compressed byte numbers.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
This artifact has no additional documented lifecycle event flow.
Direct coded failures
This artifact directly assigns no stable coded failure.
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- RangeError for mismatched frame dimensions
- Error when encoding without frames
Availability and capabilities
Cross-host. Normalized byte output and bounds.
Cross-host first-party bounded GIF encoding with no Core dependency.
Contract example
import GifEncoder from '/arcane/modules/GifEncoder.js';
const encoder=new GifEncoder(1,1);
encoder.addFrame(
new ImageData(new Uint8ClampedArray([255,0,0,255]),1,1),
{delay:100}
);
console.log(encoder.encode());
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.