Skip to content

Commit 8051f61

Browse files
committed
refactor: improve type safety in transformation string construction and update supported transforms
1 parent 727dae4 commit 8051f61

File tree

3 files changed

+375
-151
lines changed

3 files changed

+375
-151
lines changed

src/constants/supportedTransforms.ts

Lines changed: 42 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,64 @@
11
/**
2-
* @link https://docs.imagekit.io/features/image-transformations
2+
* @link https://imagekit.io/docs/transformations
33
*/
44
const supportedTransforms: { [key: string]: string } = {
5-
/**
6-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#width-w
7-
*/
8-
width: "w",
9-
10-
/**
11-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#height-h
12-
*/
13-
height: "h",
14-
15-
/**
16-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#aspect-ratio-ar
17-
*/
185
aspectRatio: "ar",
19-
20-
/**
21-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#quality-q
22-
*/
23-
quality: "q",
24-
25-
/**
26-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#crop-crop-modes-and-focus
27-
*/
6+
background: "bg",
7+
border: "b",
288
crop: "c",
29-
30-
/**
31-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#crop-crop-modes-and-focus
32-
*/
339
cropMode: "cm",
34-
35-
/**
36-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#focus-fo
37-
*/
10+
DPR: "dpr",
3811
focus: "fo",
39-
40-
/**
41-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#examples-focus-using-cropped-image-coordinates
42-
*/
12+
quality: "q",
4313
x: "x",
44-
45-
/**
46-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#examples-focus-using-cropped-image-coordinates
47-
*/
14+
xCenter: "xc",
4815
y: "y",
49-
50-
/**
51-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#format-f
52-
*/
16+
yCenter: "yc",
17+
height: "h",
18+
width: "w",
5319
format: "f",
54-
55-
/**
56-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#radius-r
57-
*/
20+
videoCodec: "vc",
21+
audioCodec: "ac",
5822
radius: "r",
59-
60-
/**
61-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#background-color-bg
62-
*/
63-
background: "bg",
64-
65-
/**
66-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#border-b
67-
*/
68-
border: "b",
69-
70-
/**
71-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#rotate-rt
72-
*/
7323
rotation: "rt",
74-
75-
/**
76-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#rotate-rt
77-
*/
7824
rotate: "rt",
79-
80-
/**
81-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#blur-bl
82-
*/
8325
blur: "bl",
84-
85-
/**
86-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#named-transformation-n
87-
*/
8826
named: "n",
89-
90-
/**
91-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#progressive-image-pr
92-
*/
93-
progressive: "pr",
94-
95-
/**
96-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#lossless-webp-and-png-lo
97-
*/
98-
lossless: "lo",
99-
100-
/**
101-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#trim-edges-t
102-
*/
103-
trim: "t",
104-
105-
/**
106-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#image-metadata-md
107-
*/
108-
metadata: "md",
109-
110-
/**
111-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#color-profile-cp
112-
*/
113-
colorProfile: "cp",
114-
115-
/**
116-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#default-image-di
117-
*/
11827
defaultImage: "di",
119-
120-
/**
121-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#dpr-dpr
122-
*/
123-
dpr: "dpr",
124-
125-
/**
126-
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#sharpen-e-sharpen
127-
*/
128-
effectSharpen: "e-sharpen",
129-
130-
/**
131-
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#unsharp-mask-e-usm
132-
*/
133-
effectUSM: "e-usm",
134-
135-
/**
136-
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#contrast-stretch-e-contrast
137-
*/
138-
effectContrast: "e-contrast",
139-
140-
/**
141-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#grayscale-e-grayscale
142-
*/
143-
effectGray: "e-grayscale",
144-
145-
/**
146-
* @link https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#original-image-orig
147-
*/
28+
flip: "fl",
14829
original: "orig",
149-
150-
/**
151-
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#shadow-e-shadow
152-
*/
30+
startOffset: "so",
31+
endOffset: "eo",
32+
duration: "du",
33+
streamingResolutions: "sr",
34+
eGrayscale: "e-grayscale",
35+
eRemoveDotBg: "e-removedotbg",
36+
eUpscale: "e-upscale",
37+
eRetouch: "e-retouch",
38+
eGenvar: "e-genvar",
39+
eDropshadow: "e-dropshadow",
40+
eChangeBg: "e-changebg",
41+
eBgRemove: "e-bgremove",
42+
eContrast: "e-contrast",
43+
eShadow: "e-shadow",
44+
eSharpen: "e-sharpen",
45+
eUSM: "e-usm",
46+
eGradient: "e-gradient",
47+
effectContrast: "e-contrast",
15348
effectShadow: "e-shadow",
154-
155-
/**
156-
* @link https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#gradient-e-gradient
157-
*/
49+
effectSharpen: "e-sharpen",
50+
effectUSM: "e-usm",
15851
effectGradient: "e-gradient",
159-
160-
/**
161-
* @link https://docs.imagekit.io/features/image-transformations/conditional-transformations
162-
*/
163-
raw: "raw",
52+
effectGray: "e-grayscale",
53+
progressive: "pr",
54+
lossless: "lo",
55+
colorProfile: "cp",
56+
metadata: "md",
57+
opacity: "o",
58+
trim: "t",
59+
zoom: "z",
60+
page: "pg",
61+
raw: "raw",
16462
}
16563

16664

0 commit comments

Comments
 (0)