-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bindings.d.ts
89 lines (87 loc) · 2.51 KB
/
bindings.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
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export const enum PixelFormat {
Rgba = 0,
Rgb = 1
}
export const enum ResizeMode {
Exact = 0,
Fill = 1,
Fit = 2
}
export interface ImageInfo {
format: PixelFormat
width: number
height: number
}
export const enum RotationMode {
CW90 = 0,
CW180 = 1,
CW270 = 2
}
export interface TransformOptions {
scaleMode?: ResizeMode
flipH?: boolean
flipV?: boolean
rotation?: RotationMode
}
export class ImageTransformer {
/**
* Create an `ImageTransformer` from a `Buffer` or `Uint8Array`
*
* @param buffer - The image to transform
* @param width - Width of the image
* @param height - Height of the image
* @param format - Pixel format of the buffer
*/
static fromBuffer(buffer: Uint8Array, width: number, height: number, format: PixelFormat): ImageTransformer
/**
* Add a scale step to the transform sequence
*
* @param width - Target width for the image
* @param height - Target height for the image
* @param mode - Method to use when source and target aspect ratios do not match
*/
scale(width: number, height: number, mode?: ResizeMode | undefined | null): this
/**
* Add a crop step to the transform sequence
*
* @param x - X offset for the crop
* @param y - Y offset for the crop
* @param width - Target width for the image
* @param height - Target height for the image
*/
crop(x: number, y: number, width: number, height: number): this
/**
* Add a center crop step to the transform sequence
*
* @param width - Target width for the image
* @param height - Target height for the image
*/
cropCenter(width: number, height: number): this
/** Add a vertical flip step to the transform sequence */
flipVertical(): this
/** Add a horizontal flip step to the transform sequence */
flipHorizontal(): this
/**
* Add a rotation step to the transform sequence
*
* @param rotation - The amount to rotate by
*/
rotate(rotation: RotationMode): this
/**
* Convert the transformed image to a Buffer
*
* Danger: This is performed synchronously on the main thread, which can become a performance bottleneck. It is advised to use `toBuffer` whenever possible
*
* @param format - The pixel format to pack into the buffer
*/
toBufferSync(format: PixelFormat): Buffer
/**
* Asynchronously convert the transformed image to a Buffer
*
* @param format - The pixel format to pack into the buffer
*/
toBuffer(format: PixelFormat): Promise<Buffer>
}