/
ImageMetadataFormat.ts
83 lines (74 loc) · 2.25 KB
/
ImageMetadataFormat.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
/**
* Metadata for inline image resize
*/
export type ImageResizeMetadataFormat = {
/**
* Width after resize, in px.
* If image is cropped, this is the width of visible part
* If image is rotated, this is the width before rotation
* @default clientWidth of the image
*/
widthPx?: number;
/**
* Height after resize, in px.
* If image is cropped, this is the height of visible part
* If image is rotated, this is the height before rotation
* @default clientHeight of the image
*/
heightPx?: number;
};
/**
* Metadata for inline image crop
*/
export type ImageCropMetadataFormat = {
/**
* Left cropped percentage. Rotation or resizing won't impact this percentage value
* @default 0
*/
leftPercent?: number;
/**
* Right cropped percentage. Rotation or resizing won't impact this percentage value
* @default 0
*/
rightPercent?: number;
/**
* Top cropped percentage. Rotation or resizing won't impact this percentage value
* @default 0
*/
topPercent?: number;
/**
* Bottom cropped percentage. Rotation or resizing won't impact this percentage value
* @default 0
*/
bottomPercent?: number;
};
/**
* Metadata for inline image rotate
*/
export type ImageRotateMetadataFormat = {
/**
* Rotated angle of inline image, in radian. Cropping or resizing won't impact this percentage value
* @default 0
*/
angleRad?: number;
};
/**
* Metadata for inline image
*/
export type ImageMetadataFormat = ImageResizeMetadataFormat &
ImageCropMetadataFormat &
ImageRotateMetadataFormat & {
/**
* Original src of the image. This value will not be changed when edit image. We can always use it
* to get the original image so that all editing operation will be on top of the original image.
*/
readonly src?: string;
/**
* Natural width of the original image (specified by the src field, may not be the current edited image)
*/
readonly naturalWidth?: number;
/**
* Natural height of the original image (specified by the src field, may not be the current edited image)
*/
readonly naturalHeight?: number;
};