-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
50 lines (50 loc) · 1.43 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
/**
* Compress image file while preserving the aspect ratio.
* @param img img element
* @param settings Settings { maxWidth: number, maxHeight: number, quality: number }
*/
export declare function compressWithRatio(img: HTMLImageElement, settings: ISettings): string;
/**
* Read base64 content from a File object
* @param file A single file obtained by input[type=file]
*/
export declare function readFile(file: File): Promise<string>;
/**
* Convert base64 image to File object
* @param dataUrl base64 image
* @param filename file name
*/
export declare function dataURLtoFile(dataUrl: string, filename: string): File;
/**
* Compress file to specified width & height
* @param img img element
* @param width width
* @param height height
* @param options options { quality?: number, mineType?: string = 'image/png' }
*/
export declare function compress(img: HTMLImageElement, width: number, height: number, options: IOptions): string;
/**
* Create a HTMLImageElement
* @param src image url
*/
export declare function createImage(src: string): Promise<HTMLImageElement>;
export interface IOptions {
/**
* image quality(0~1)
*/
quality?: number;
/**
* output MINE type. default to image/png
*/
mineType?: string;
}
export interface ISettings extends IOptions {
/**
* the max width when resize
*/
maxWidth?: number;
/**
* the max height when resize
*/
maxHeight?: number;
}