@mescius/dsimageviewer
Version:
Document Solutions Image Viewer
66 lines (65 loc) • 1.87 kB
TypeScript
/**
* Information about GIF frame.
**/
export declare type FrameInfo = {
data_length: number;
data_offset: number;
delay: number;
disposal: number;
has_local_palette: boolean;
height: number;
interlaced: boolean;
palette_offset: number;
palette_size: number;
transparent_index: any;
width: number;
x: number;
y: number;
};
/**
* GIF frame data.
**/
export declare type GifFrame = {
getImage: () => HTMLImageElement | HTMLCanvasElement;
frameIndex: number;
frameInfo: FrameInfo;
};
/**
* GIF image parser options;
**/
export declare type GifParserOptions = {
/**
* Url to GIF image, or binary data buffer
**/
url: string;
/**
* The set of frames to extract.
**/
frames?: "all" | number;
/**
* Maximum image buffer length to load.
* The image buffer length is calculated as follows:
* `NumFrames * image.height * image.width * 4`.
* If the GIF image exceeds this value, only the first frame will be loaded.
* The default and maximum value is 2145386496.
**/
maxBufferLength?: number;
/**
* Type of the image to save. Currently supported formats
* @default canvas
**/
outputType?: "png" | "gif" | "canvas";
/**
* Many animated GIFs will only contain partial image information in each frame after the first.
* Specifying cumulative as true will compute each frame by layering it on top of previous frames.
* Note: the cost of this computation is proportional to the size of the last requested frame index.
**/
cumulative?: boolean;
};
/**
* GIF image parser.
* based on https://github.com/benwiley4000/gif-frames
**/
export declare class GifParser {
static parse(options: GifParserOptions): Promise<GifFrame[]>;
}