forked from jimp-dev/jimp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jimp.d.ts
133 lines (112 loc) · 5.32 KB
/
jimp.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
declare namespace Jimp {
type ImageCallback = (err: Error|null, image: Jimp) => any;
interface RGB {
r: number;
g: number;
b: number;
}
interface RGBA {
r: number;
g: number;
b: number;
a: number;
}
interface Jimp {
bitmap: {data: Buffer, width: number, height: number};
clone(cb?: Jimp.ImageCallback): Jimp;
quality(n: number, cb?: Jimp.ImageCallback): this;
deflateLevel(l: number, cb?: Jimp.ImageCallback): this;
deflateStrategy(s: number, cb?: Jimp.ImageCallback): this;
filterType(f: number, cb?: Jimp.ImageCallback): this;
rgba(bool: boolean, cb?: Jimp.ImageCallback): this;
background(hex: number, cb?: Jimp.ImageCallback): this;
scan(x: number, y: number, w: number, h: number, f: (x:number, y:number, idx:number)=>any, cb?: Jimp.ImageCallback): this;
getMIME(): string;
getExtension(): string;
getPixelIndex(x: number, y: number, cb?: (err:Error, i:number)=>any): number;
getPixelColor(x: number, y: number, cb?: (err:Error, hex:number)=>any): number;
setPixelColor(hex: number, x: number, y: number, cb?: Jimp.ImageCallback): this;
hash(base?: number, cb?: (err:Error, hash: string)=>any): string;
crop(x: number, y: number, w: number, h: number, cb?: Jimp.ImageCallback): this;
autocrop(tolerance?: number, cropOnlyFrames?: boolean, cb?: Jimp.ImageCallback): this
blit(src: Jimp, x: number, y: number, srcx?: number, srcy?: number, srcw?: number, srch?: number, cb?: Jimp.ImageCallback): this
mask(src: Jimp, x: number, y: number, cb?: Jimp.ImageCallback): this
composite(src: Jimp, x: number, y: number, cb?: Jimp.ImageCallback): this;
brightness(val: number, cb?: Jimp.ImageCallback): this;
contrast(val: number, cb?: Jimp.ImageCallback): this;
posterize(n: number, cb?: Jimp.ImageCallback): this;
histogram(): {r: number[], g: number[], b: number[]};
normalize(cb?: Jimp.ImageCallback): this;
invert(cb?: Jimp.ImageCallback): this;
mirror(horizontal: boolean, vertical: boolean, cb?: Jimp.ImageCallback): this;
gaussian(r: number, cb?: Jimp.ImageCallback): this;
blur(r: number, cb?: Jimp.ImageCallback): this;
greyscale(cb?: Jimp.ImageCallback): this;
grayscale(cb?: Jimp.ImageCallback): this;
sepia(cb?: Jimp.ImageCallback): this;
opacity(f: any, cb?: any):this;
fade(f: any, cb?: any): this;
opaque(cb: any): this;
resize(w: number, h: number, mode?: string, cb?: Jimp.ImageCallback): this;
cover(w: number, h: number, alignBits?: number, mode?: string, cb?: Jimp.ImageCallback): this;
contain(w: number, h: number, alignBits?: number, mode?: string, cb?: Jimp.ImageCallback): this;
scale(f: number, mode?: string, cb?: Jimp.ImageCallback): this;
scaleToFit(w: number, h: number, mode?: any, cb?: Jimp.ImageCallback): this;
rotate(deg: number, mode?: number|boolean, cb?: Jimp.ImageCallback): this;
getBuffer(mime: string, cb:(err:Error, buffer:Buffer)=>any): this;
write(path: string, cb?: Jimp.ImageCallback): this;
}
var Jimp: {
// used to auto resizing etc.
AUTO: number;
// supported mime types
MIME_PNG: string;
MIME_JPEG: string;
MIME_BMP: string;
// PNG filter types
PNG_FILTER_AUTO: number;
PNG_FILTER_NONE: number;
PNG_FILTER_SUB: number;
PNG_FILTER_UP: number;
PNG_FILTER_AVERAGE: number;
PNG_FILTER_PAETH: number;
// resize methods
RESIZE_NEAREST_NEIGHBOR: string;
RESIZE_BILINEAR: string;
RESIZE_BICUBIC: string;
RESIZE_HERMITE: string;
RESIZE_BEZIER: string;
// Align modes for cover, contain, bit masks
HORIZONTAL_ALIGN_LEFT: number;
HORIZONTAL_ALIGN_CENTER: number;
HORIZONTAL_ALIGN_RIGHT: number;
VERTICAL_ALIGN_TOP: number;
VERTICAL_ALIGN_MIDDLE: number;
VERTICAL_ALIGN_BOTTOM: number;
// Font locations
FONT_SANS_8_BLACK: string;
FONT_SANS_16_BLACK: string;
FONT_SANS_32_BLACK: string;
FONT_SANS_64_BLACK: string;
FONT_SANS_128_BLACK: string;
FONT_SANS_8_WHITE: string;
FONT_SANS_16_WHITE: string;
FONT_SANS_32_WHITE: string;
FONT_SANS_64_WHITE: string;
FONT_SANS_128_WHITE: string;
(path: string, cb?: Jimp.ImageCallback): Jimp;
(image: Jimp, cb?: Jimp.ImageCallback): Jimp;
(data: Buffer, cb?: Jimp.ImageCallback): Jimp;
(w: number, h: number, cb?: Jimp.ImageCallback): Jimp;
read(src: string|Buffer, cb?: Jimp.ImageCallback): Promise<Jimp>;
rgbaToInt(r: number, g: number, b: number, a: number, cb?: (err: Error, i: number)=>any): number;
intToRgba(i: number, cb?: (err:Error, rgba: Jimp.RGBA)=>any): Jimp.RGBA;
limit255(n: number): number;
diff(img1: Jimp, img2: Jimp, threshold?: number): {percent: number, diff: Jimp};
distance(img1: Jimp, img2: Jimp): number;
prototype: Jimp;
};
}
declare module "jimp" {
export = Jimp.Jimp;
}