Represents a GIF image as an array of frames. Array methods like map and filter return plain arrays.

Hierarchy

Indexable

Constructors

Properties

Accessors

Methods

Constructors

  • Creates a new GIF image

    Parameters

    • frames: Frame[]

      The frames to create the GIF from

    • loopCount: number = -1

      How many times to repeat the GIF (-1 = forever, 0 = play once)

    Returns GIF

Properties

loopCount: number

How many times to repeat the GIF (-1 = forever, 0 = play once)

Accessors

  • get duration(): number

    The GIF's duration (in ms)

    Returns number

  • get height(): number

    The GIF's height

    Returns number

  • get width(): number

    The GIF's width

    Returns number

Methods

  • Decodes a GIF into fully composited frames

    Parameters

    • input: BinaryData

      The binary data to decode

    • onlyExtractFirstFrame: boolean = false

      Whether to end GIF decoding after the first frame

    Returns Promise<GIF>

  • Encodes the GIF

    Parameters

    • quality: number = 95

      1-100, scales the palette size from 8 colors (1) to 256 colors (90 and above)

    Returns Promise<Uint8Array<ArrayBufferLike>>

  • Resizes the GIF 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.

    Parameters

    • width: number
    • height: number
    • mode: ResizeMode = Image.RESIZE_BILINEAR

    Returns this

  • Returns a new GIF containing a range of this GIF's frames (same semantics as Array.prototype.slice)

    Parameters

    • Optionalstart: number
    • Optionalend: number

    Returns GIF

  • Returns a string representation of an array.

    Returns string