Menu

Class GifImage

GIF image encoder

Supports static single-frame GIF export as well as animated GIF

Hierarchy

Index

Constructors

constructor

  • Create a new GIF image object

    Parameters

    • width: number

      image width

    • height: number

      image height

    • Default value settings: Partial<GifImageSettings> = {}

      whether the gif should loop, the delay between frames, etc. See {@link GifEncoderSettings}

    Returns GifImage

Properties

dataUrl

dataUrl: string = null

frameCount

frameCount: number = 0

Number of current GIF frames

height

height: number

Image height

mimeType

mimeType: string = "gif/image"

palette

palette: GifPaletteColor[]

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

settings

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

width

width: number

Image width

Methods

finish

  • finish(): void

getArrayBuffer

  • getArrayBuffer(): ArrayBufferLike

getBlob

  • getBlob(): Blob

getBuffer

  • getBuffer(): Buffer

getImage

  • getImage(): HTMLImageElement
  • Returns the GIF image data as an Image object

    Note: This method does not work outside of browser environments

    Returns HTMLImageElement

getUrl

  • getUrl(): string

revokeUrl

  • revokeUrl(): void

writeFrame

  • writeFrame(pixels: Uint8Array): void
  • Add a frame to the GIF image

    Parameters

    • pixels: Uint8Array

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

    Returns void

Static fromFlipnote

  • 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

    Returns GifImage

Static fromFlipnoteFrame

  • Create an GIF image from a single Flipnote frame

    Parameters

    • flipnote: Flipnote
    • frameIndex: number

      animation frame index to encode

    • Default value settings: Partial<GifImageSettings> = {}

      whether the gif should loop, the delay between frames, etc. See {@link GifEncoderSettings}

    Returns GifImage

Object literals

Static defaultSettings

defaultSettings: object

Default GIF encoder settings

colorDepth

colorDepth: number = 8

delay

delay: number = 100

repeat

repeat: number = -1