Creates a new GIF image
The frames to create the GIF from
OptionalloopCountOrOptions: number | AnimationOptionsHow many times to repeat the GIF (-1 = forever, 0 = play once), or see AnimationOptions
How many times to repeat the animation (-1 = forever, 0 = play once)
The animation's duration (in ms)
The animation's frames: an array that changes the animation when it's changed (e.g. push(), splice(), or
setting an index), and can be replaced as a whole
The animation's height
The animation's width
StaticapngAn encoder that makes an APNG a frame at a time, like Animation.encodeAPNG (the same file), keeping the
frames only compressed (the pixel format depends on all of them): await encoder.add(frame) for each frame,
then await encoder.finish()
The canvas width
The canvas height
StaticdecodeDecodes a GIF into fully composited frames
The binary data to decode
Whether to end GIF decoding after the first frame, or see AnimationDecodeOptions
Use Animation.decode, which decodes APNGs too
Encodes the GIF
OptionalqualityOrOptions: number | GIFEncodeOptions1-100, scales the palette size from 8 colors (1) to 256 colors (90 and above), or see GIFEncodeOptions
Encodes the animation as APNG (animated PNG, lossless and with full alpha). Viewers without APNG support show
the first frame. Each frame is stored as the area that changed since the frame before, identical frames are
merged (unless the optimize option is false): the file shows exactly the same animation, but doesn't
necessarily decode to the same frames
Optionaloptions: APNGEncodeOptionsEncodes the animation as APNG (animated PNG, lossless and with full alpha). Viewers without APNG support show
the first frame. Each frame is stored as the area that changed since the frame before, identical frames are
merged (unless the optimize option is false): the file shows exactly the same animation, but doesn't
necessarily decode to the same frames
Optionalcompression: numberThe zlib compression level (0-9), higher is smaller but slower
Encodes the animation as GIF. Like all encoders, it stores each frame as the area that changed since the frame
before and merges identical frames (unless the optimize option is false), so the file decodes to what the
animation shows, but not necessarily to the same frames. Semi-transparent pixels become opaque or transparent
after the frames are composited
Optionaloptions: GIFEncodeOptionsSee GIFEncodeOptions
Encodes the animation as GIF. Like all encoders, it stores each frame as the area that changed since the frame
before and merges identical frames (unless the optimize option is false), so the file decodes to what the
animation shows, but not necessarily to the same frames. Semi-transparent pixels become opaque or transparent
after the frames are composited
Optionalquality: number1-100, scales the palette size from 8 colors (1) to 256 colors (90 and above)
Encodes the animation as animated WebP, lossless or (with a quality) lossy. Each frame is stored as the area that
changed since the frame before, identical frames are merged (unless the optimize option is false): the file
shows the same animation, but doesn't necessarily decode to the same frames
StaticgifAn encoder that makes an animated GIF a frame at a time, like Animation.encodeGIF (the same file),
without keeping the frames in memory: await encoder.add(frame) for each frame, then await encoder.finish()
The canvas width
The canvas height
Resizes the animation to the given dimensions, scaling every frame and its offsets proportionally. Use Image.RESIZE_AUTO as either width or height to automatically preserve the aspect ratio.
Optionaloptions: ResizeOptionsResizes the animation to the given dimensions, scaling every frame and its offsets proportionally. Use Image.RESIZE_AUTO as either width or height to automatically preserve the aspect ratio.
Optionalmode: ResizeModeReturns a new animation of the same class containing a range of this one's frames (same semantics as Array.prototype.slice)
Optionalstart: numberOptionalend: numberA short description for debugging, e.g. GIF<64x64x1000ms>
StaticwebpAn encoder that makes an animated WebP a frame at a time, like Animation.encodeWebP (the same file),
without keeping the frames in memory: await encoder.add(frame) for each frame (a Frame, or an image
with { duration }), then await encoder.finish() for the file
The canvas width
The canvas height
Represents a GIF image as an array of frames, an Animation whose
encode()anddecode()work with GIFs. Array methods like map and filter return plain arrays.Deprecated
Use Animation, which works the same and also handles APNG:
new Animation(frames, loopCount), Animation.decode and Animation.encodeGIF.GIFwill be removed in 4.0