Skip to content

GifImage

Defined in: src/encoders/GifImage.ts:52

GIF image encoder, supports static single-frame GIF export as well as animated GIF.

Extends

  • EncoderBase

Constructors

new GifImage()

new GifImage(width, height, settings): GifImage

Defined in: src/encoders/GifImage.ts:95

Create a new GIF image object.

Parameters

ParameterTypeDescription
widthnumberImage width
heightnumberImage height
settingsPartial<GifImageSettings>Whether the gif should loop, the delay between frames, etc. See GifEncoderSettings

Returns

GifImage

Overrides

EncoderBase.constructor

Properties

dataUrl

dataUrl: string = null

Defined in: src/encoders/EncoderBase.ts:6

Inherited from

EncoderBase.dataUrl


defaultSettings

static defaultSettings: GifImageSettings

Defined in: src/encoders/GifImage.ts:57

Default GIF encoder settings


mimeType

readonly mimeType: "gif/image" = 'gif/image'

Defined in: src/encoders/GifImage.ts:63

Overrides

EncoderBase.mimeType


width

width: number

Defined in: src/encoders/GifImage.ts:67

Image width (in pixels).


height

height: number

Defined in: src/encoders/GifImage.ts:71

Image height (in pixels).


palette

palette: GifPaletteColor[]

Defined in: src/encoders/GifImage.ts:75

GIF global RGBA color palette. Max 256 colors, alpha channel is ignored.


settings

settings: GifImageSettings

Defined in: src/encoders/GifImage.ts:79

GIF image settings, such as whether it should loop, the delay between frames, etc.


frameCount

frameCount: number = 0

Defined in: src/encoders/GifImage.ts:83

Number of current GIF frames.

Methods

getBuffer()

getBuffer(): Buffer

Defined in: src/encoders/EncoderBase.ts:18

Returns the file data as a NodeJS Buffer.

Note: This method does not work outside of NodeJS environments.

Returns

Buffer

Inherited from

EncoderBase.getBuffer


getBlob()

getBlob(): Blob

Defined in: src/encoders/EncoderBase.ts:26

Returns the file data as a Blob.

Returns

Blob

Inherited from

EncoderBase.getBlob


getUrl()

getUrl(): string

Defined in: src/encoders/EncoderBase.ts:38

Returns the file data as an Object URL.

Note: This method does not work outside of browser environments.

Returns

string

Inherited from

EncoderBase.getUrl


revokeUrl()

revokeUrl(): void

Defined in: src/encoders/EncoderBase.ts:50

Revokes this file’s Object URL if one has been created, use this when the url created with getUrl is no longer needed, to preserve memory.

Note: This method does not work outside of browser environments.

Returns

void

Inherited from

EncoderBase.revokeUrl


fromFlipnote()

static fromFlipnote(flipnote, settings): GifImage

Defined in: src/encoders/GifImage.ts:111

Create an animated GIF image from a Flipnote.

This will encode the entire animation, so depending on the number of frames it could take a while to return.

Parameters

ParameterTypeDescription
flipnoteBaseParserFlipnote object (PpmParser or KwzParser instance)
settingsPartial<GifImageSettings>Whether the gif should loop, the delay between frames, etc. See GifEncoderSettings

Returns

GifImage


fromFlipnoteFrame()

static fromFlipnoteFrame(flipnote, frameIndex, settings): GifImage

Defined in: src/encoders/GifImage.ts:133

Create an GIF image from a single Flipnote frame.

Parameters

ParameterTypeDescription
flipnoteBaseParser
frameIndexnumberanimation frame index to encode
settingsPartial<GifImageSettings>whether the gif should loop, the delay between frames, etc. See GifEncoderSettings

Returns

GifImage


writeFrame()

writeFrame(pixels): void

Defined in: src/encoders/GifImage.ts:149

Add a frame to the GIF image.

Parameters

ParameterTypeDescription
pixelsUint8ArrayRaw pixels to encode, must be an uncompressed 8bit array of palette indices with a size matching image width * image height

Returns

void


finish()

finish(): void

Defined in: src/encoders/GifImage.ts:160

Call once all frames have been written to finish the GIF image.

Returns

void


getArrayBuffer()

getArrayBuffer(): ArrayBufferLike

Defined in: src/encoders/GifImage.ts:167

Returns the GIF image data as an ArrayBuffer.

Returns

ArrayBufferLike

Overrides

EncoderBase.getArrayBuffer


getImage()

getImage(): HTMLImageElement

Defined in: src/encoders/GifImage.ts:176

Returns the GIF image data as an Image object.

Note: This method does not work outside of browser environments

Returns

HTMLImageElement