-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.d.ts
159 lines (148 loc) · 4.28 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import { Color, RawOptions, ResizeOptions, Sharp, SharpOptions } from "sharp";
/**
* gifenc GIFEncoder options
*/
export declare interface GifEncoderOptions {
auto?: Boolean;
initialCapacity?: Number;
}
/**
* gifenc quantize() options
*/
export declare interface GifEncoderQuantizeOptions {
format?: "rgb565" | "rgb444" | "rgba4444";
oneBitAlpha?: Boolean | Number;
clearAlpha?: Boolean;
clearAlphaThreshold?: Number;
clearAlphaColor?: Number;
}
/**
* gifenc gif.writeFrame() options
*/
export declare interface GifEncoderFrameOptions {
palette?: Number[][];
first?: Boolean;
transparent?: Boolean;
transparentIndex?: Number;
delay?: Number;
repeat?: Number;
dispose?: Number;
}
/**
* gifenc GIFEncoder
*/
export declare interface GIFEncoder {
readonly buffer: ArrayBufferLike;
readonly stream: {
readonly buffer: ArrayBufferLike;
reset(): void;
bytes(): Uint8Array;
bytesView(): Uint8Array;
writeByte(byte: Number): void;
writeBytes(data: Number[], offset: Number, byteLength: Number): void;
writeBytesView(data: Uint8Array, offset: Number, byteLength: Number): void;
};
finish(): void;
bytes(): Uint8Array;
bytesView(): Uint8Array;
writeHeader(): void;
writeFrame(
index: Uint8Array,
width: Number,
height: Number,
opts: GifEncoderFrameOptions
): void;
reset(): void;
}
/**
* Gif options
* @param gifEncoderOptions - gifenc GIFEncoder() options.
* @param gifEncoderQuantizeOptions - gifenc quantize() options.
* @param gifEncoderFrameOptions - gifenc gif.writeFrame() options.
* @param sharpOptions - sharp constructor options.
* @param width - Width, in pixels, of the GIF to output.
* @param height - Height, in pixels, of the GIF to output.
* @param delay - Delay(s) between animation frames (in milliseconds).
* @param repeat - Number of animation iterations, use `0` for infinite animation. Default by `0`.
* @param transparent - Enable 1-bit transparency for the GIF.
* @param maxColors - Quantize the total number of colors down to a reduced palette no greater than maxColors. Default by `256`.
* @param format - Color format. Default by `"rgb565"`.
* @param resizeTo - Resize all frame to the `largest` frame or `smallest` frame size.
* @param resizeType - Resize type, `zoom` or `crop`.
* @param resizeOptions - sharp resize options.
* @param extendBackground - sharp extend background option.
* @param rawOptions - sharp raw options.
* @public
*/
export declare interface GifOptions {
gifEncoderOptions?: GifEncoderOptions;
gifEncoderQuantizeOptions?: GifEncoderQuantizeOptions;
gifEncoderFrameOptions?: GifEncoderFrameOptions;
sharpOptions?: SharpOptions;
width?: Number;
height?: Number;
delay?: Number | Number[];
repeat?: Number;
transparent?: Boolean;
maxColors?: Number;
format?: "rgb565" | "rgb444" | "rgba4444";
resizeTo?: "largest" | "smallest";
resizeType?: "zoom" | "crop";
resizeOptions?: ResizeOptions;
extendBackground?: Color;
rawOptions?: RawOptions;
}
export declare interface EncodeProgressHandler {
(progress: { total: Number; encoded: Number }): void;
}
/**
* Gif
*/
export declare class Gif {
constructor(options?: GifOptions);
/**
* Add new frames
* @param frame
*/
addFrame(frame: Sharp | Sharp[]): Gif;
/**
* Create a GIFEncoder
* @param width
* @param height
* @param gifEncoderOptions
*/
getEncoder(gifEncoderOptions?: GifEncoderOptions): GIFEncoder;
/**
* Encode all frames and resolve with an animated GIF buffer
* @param encoder
*/
toBuffer(progress?: EncodeProgressHandler, encoder?: GIFEncoder): Promise<Buffer>;
/**
* Encode all frames and resolve with an animated sharp instance
* @param encoder
*/
toSharp(progress?: EncodeProgressHandler, encoder?: GIFEncoder): Promise<Sharp>;
}
export declare interface CutProgressHandler {
(progress: { total: Number; cutted: Number }): void;
}
export declare class GifReader {
constructor(image: Sharp);
/**
* Cut GIF frames
*/
toFrames(progress?: CutProgressHandler): Promise<Sharp[]>;
/**
* Create Gif from cutted frames
* @param options
*/
toGif(options?: GifOptions): Promise<Gif>;
}
/**
* Create Gif
*/
export declare function createGif(options?: GifOptions): Gif;
/**
* Read Gif
*/
export declare function readGif(image: Sharp): GifReader;