Class DecodeOptions

Options for opening a GIF decoder. <DecodeOptions>.readInfo will create a decoder with these options.

Constructors

Methods

  • Configure if unknown blocks are allowed to be decoded.

    Parameters

    • value: boolean

      Whether to allow unknown blocks. The default is false. When turned on, the decoder will allow unknown blocks to be in the BlockStart position. When turned off, decoded block starts must mark an Image, Extension, or Trailer block. Otherwise, the decoded image will return an error. If an unknown block error is returned from decoding, enabling this setting may allow for a further state of decoding on the next attempt.

    Returns void

  • Configure if frames must be within the screen descriptor.

    Parameters

    • value: boolean

      Whether to check frame consistency. The default is false. When turned on, all frame descriptors being read must fit within the screen descriptor or otherwise an error is returned and the stream left in an unspecified state. When turned off, frames may be arbitrarily larger or offset in relation to the screen. Many other decoder libraries handle this in highly divergent ways. This moves all checks to the caller, for example to emulate a specific style.

    Returns void

  • Configure if LZW encoded blocks must end with a marker end code.

    Parameters

    • value: boolean

      Whether to check for the end code. The default is false. When turned on, all image data blocks—which are LZW encoded—must contain a special bit sequence signalling the end of the data. LZW processing terminates when this code is encountered. The specification states that it must be the last code output by the encoder for an image. When turned off then image data blocks can simply end. Note that this might silently ignore some bits of the last or second to last byte.

    Returns void

  • Reads the logical screen descriptor including the global color palette Returns a Decoder. All decoder configuration has to be done beforehand.

    Parameters

    • buffer: Uint8Array

      The GIF buffer to decode.

    Returns Decoder

  • Configure how color data is decoded.

    Parameters

    Returns void

  • Configure a memory limit for decoding.

    Parameters

    • value: number

      The memory limit in bytes. Negative values are treated as unlimited. (e.g. -1) If the provided value is -1, the memory limit is set to unlimited. If a positive integer is provided, the memory limit will be set in bytes. A non-zero integer is required for this case, and any non-integer or invalid value will return an error.

    Returns void

  • Configure whether to skip decoding frames.

    Parameters

    • value: boolean

      Whether to skip frame decoding. The default is false. When turned on, LZW decoding is skipped. <Decoder>.readNextFrame will return compressed LZW bytes in frame’s data. <Decoder>.nextFrameInfo will return the metadata of the next frame as usual. This is useful to count frames without incurring the overhead of decoding.

    Returns void