Class

GIF

GIF(frames, loopCountopt)

Represents a GIF image as an array of frames

Constructor

# new GIF(frames, loopCountopt)

Creates a new GIF image.

Parameters:
Name Type Attributes Default Description
frames Array.<Frame>

The frames to create the GIF from

loopCount number <optional>
-1

How often to loop the GIF for (-1 = unlimited)

Properties:
Name Type Description
loopCount number

How often the GIF will loop for

View Source ImageScript.js, line 1335

Extends

Members

# duration

The GIFs duration (in ms)

View Source ImageScript.js, line 1410

# height

The GIFs height

View Source ImageScript.js, line 1374

# width

The GIFs width

View Source ImageScript.js, line 1359

Methods

# async encode(qualityopt) → {Promise.<Uint8Array>}

Encodes the image into a GIF

Parameters:
Name Type Attributes Default Description
quality number <optional>
95

GIF quality 0-100

View Source ImageScript.js, line 1419

The encoded data

Promise.<Uint8Array>

# async static decode(data, onlyExtractFirstFrameopt) → {Promise.<GIF>}

Decodes a GIF image

Parameters:
Name Type Attributes Default Description
data Buffer | Uint8Array

The binary data to decode

onlyExtractFirstFrame boolean <optional>
false

Whether to end GIF decoding after the first frame

View Source ImageScript.js, line 1447

The decoded GIF

Promise.<GIF>