forked from zhangyuanwei/node-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
88 lines (59 loc) · 2.92 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
/// <reference types="node" />
export = images;
declare namespace images {
interface EncoderConfig {
[key: string]: number | string;
quality?: number;
}
type FILE_TYPE = "png" | "jpg" | "jpeg" | "gif" | "bmp" | "raw";
const enum TYPE {
TYPE_PNG = 1,
TYPE_JPEG,
TYPE_GIF,
TYPE_BMP,
TYPE_RAW,
TYPE_WEBP,
}
class Image {
loadFromBuffer(buffer: Buffer, start?: number, end?: number): this;
copyFromImage(img: Image, x: number, y: number, width: number, height: number): this;
copyFromImage(img: Image, x: number, y: number): this;
copyFromImage(img: Image): this;
fill(red: number, green: number, blue: number, alpha?: number): this;
fillColor = this.fill;
draw(img: Image, x: number, y: number): this;
drawImage = this.draw;
encode(type: FILE_TYPE | TYPE, config?: EncoderConfig): Buffer;
toBuffer = this.encode;
save(file: string, type: FILE_TYPE | TYPE, config: EncoderConfig): this;
save(file: string, config: EncoderConfig): this;
save(file: string, type: FILE_TYPE | TYPE): this;
save(file: string): this;
saveAsync(file: string, type: FILE_TYPE | TYPE, config: EncoderConfig, callback: (err: NodeJS.ErrnoException | null) => void): this;
saveAsync(file: string, type: FILE_TYPE | TYPE, callback: (err: NodeJS.ErrnoException | null) => void): this;
saveAsync(file: string, config: EncoderConfig, callback: (err: NodeJS.ErrnoException | null) => void): this;
saveAsync(file: string, callback: (err: NodeJS.ErrnoException | null) => void): this;
resize(width: number, height?: number, filter?: string): this;
rotate(deg: number): this;
size(): { width: number, height: number };
size(width: number, height?: number): this;
width(): number;
width(width: number): this;
height(): number;
height(height: number): this;
}
function loadFromFile(file: string): Image;
function createImage(width?: number, height?: number): Image;
function loadFromBuffer(buffer: Buffer, start?: number, end?: number): Image;
function copyFromImage(image: Image, x?: number, y?: number, width?: number, height?: number): Image;
function setLimit(maxWidth: number, maxHeight: number): void;
function setGCThreshold(value: number): void;
function getUsedMemory(): number;
function gc(): void;
}
declare function images(buffer: Buffer, start?: number, end?: number): images.Image;
declare function images(image: images.Image, x: number, y: number, width: number, height: number): images.Image;
declare function images(image: images.Image, x: number, y: number): images.Image;
declare function images(image: images.Image): images.Image;
declare function images(file: string): images.Image;
declare function images(width?: number, height?: number): images.Image;