Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface FormatCodec

Codec instances are created by format proxies and are responsible of encode and decode certain set of image formats. See IMPORTANT: formats are lowercase and in general the common extension of files

Hierarchy

  • FormatCodec

Implemented by

Index

Methods

decode

  • decode(buffer: ArrayBuffer, format?: undefined | string): Promise<ImageData | undefined>
  • Given an array buffer that contains the content of an encoded image it will return a decoded ImageData object. The format parameter could be needed by some poor decoders that don't support file type sniffing. For example, magica or jimp libraries don't need this.

    Parameters

    • buffer: ArrayBuffer
    • Optional format: undefined | string

    Returns Promise<ImageData | undefined>

encode

  • encode(data: ImageData, format: string, quality?: undefined | number): Promise<ArrayBuffer | undefined>
  • given an image data representing an unencoded raw image it will return an array buffer containing the enconcoded image content in given format.

    Parameters

    • data: ImageData
    • format: string
    • Optional quality: undefined | number

    Returns Promise<ArrayBuffer | undefined>

Optional getSupportedDecodeFormats

  • getSupportedDecodeFormats(): string[]
  • if provided an error will be thrown in case users request to decode to a format not included in this list.

    Returns string[]

Optional getSupportedEncodeFormats

  • getSupportedEncodeFormats(): string[]
  • if provided an error will be thrown in case users request to encode to a format not included in this list.

    Returns string[]

Generated using TypeDoc