UNPKG

image-in-browser

Version:

Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)

42 lines (41 loc) 1.43 kB
/** @format */ import { MemoryImage } from '../image/image.js'; /** * Options for encoding an image. */ export interface EncoderEncodeOptions { /** * The image to be encoded. */ image: MemoryImage; /** * Flag to indicate if only a single frame should be encoded. * - true: Encode only the first frame. * - false or undefined: Encode all frames if the encoder supports animation. */ singleFrame?: boolean; /** * Determines if EXIF metadata should be skipped during encoding. * - true: EXIF metadata will be skipped. * - false or undefined: EXIF metadata will be included in the encoded image. */ skipExif?: boolean; } /** * Base class for image format encoders. */ export interface Encoder { /** * True if the encoder supports animated images; otherwise false. */ get supportsAnimation(): boolean; /** * Encode an image to an image format. * * @param {EncoderEncodeOptions} opt - The options for encoding the image. * @param {ImageData} opt.image - The image to be encoded. * @param {boolean} opt.singleFrame - If true, only a single frame of the image will be encoded. If false or undefined, all frames of the image will be encoded if the encoder supports animation. * @returns {Uint8Array} A Uint8Array containing the encoded image data. */ encode(opt: EncoderEncodeOptions): Uint8Array; }