Skip to content

Commit 8fa1219

Browse files
committed
refactor: enhance type safety and clarity in Transformation interface
1 parent 8051f61 commit 8fa1219

File tree

1 file changed

+19
-55
lines changed

1 file changed

+19
-55
lines changed

src/interfaces/Transformation.ts

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ export interface Transformation {
4444
/**
4545
* @link https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus
4646
*/
47-
crop?: string;
47+
crop?: "force" | "at_max" | "at_max_enlarge" | "at_least" | "maintain_ratio";
4848

4949
/**
5050
* @link https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus
5151
*/
52-
cropMode?: string;
52+
cropMode?: "pad_resize" | "extract" | "pad_extract";
5353

5454
/**
5555
* Possible values 0.1 to 5 or `auto` for automatic DPR calculation.
@@ -116,12 +116,6 @@ export interface Transformation {
116116
*/
117117
rotation?: number | string;
118118

119-
/**
120-
* @deprecated Alias of `rotation`.
121-
* Prefer using `rotation` for clarity.
122-
*/
123-
rotate?: number | string;
124-
125119
/**
126120
* Gaussian blur level. Ranges 1–100 or an expression like `"bl-10"`. Possible values include integers between 1 and 100.
127121
*/
@@ -147,7 +141,7 @@ export interface Transformation {
147141
/**
148142
* Whether to serve the original file without any transformations if `true`.
149143
*/
150-
original?: boolean
144+
original?: true
151145

152146
/**
153147
* Start offset (in seconds) for trimming videos. e.g., `5` or `"10.5"`.
@@ -179,107 +173,77 @@ export interface Transformation {
179173
/**
180174
* Enable grayscale effect for images.
181175
*/
182-
eGrayscale?: true;
176+
grayScale?: true;
183177

184178
/**
185179
* Use third-party background removal.
186-
* See also `eBgRemove` for ImageKit's in-house background removal which is 90% cheaper.
180+
* See also `removeBackground` for ImageKit's in-house background removal which is 90% cheaper.
187181
*/
188-
eRemoveDotBg?: true
182+
removeBackgroundThirdParty?: true
189183

190184
/**
191185
* Upscale images beyond their original dimensions with AI.
192186
*/
193-
eUpscale?: true
187+
upscale?: true
194188

195189
/**
196190
* Retouch (AI-based) for improving faces or product shots.
197191
*/
198-
eRetouch?: true
192+
retouch?: true
199193

200194
/**
201-
* Generate variations of an image using AI.
195+
* Generate variation of an image using AI. This will generate a new image with slight variations from the original image. The variations include changes in color, texture, and other visual elements. However, the model will try to preserve the structure and essence of the original image.
202196
*/
203-
eGenvar?: true
197+
generateVariation?: true
204198

205199
/**
206200
* Add an AI-based drop shadow around a foreground object on a transparent or removed background.
207201
* You can control the direction, elevation, and saturation of the light source. E.g. change light direction `az-45`.
208202
* @link https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow
209203
*/
210-
eDropshadow?: true | string
204+
AIDropshadow?: string
211205

212206
/**
213207
* Change background using AI. Provide a prompt or base64-encoded prompt. e.g. `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`.
214208
*/
215-
eChangeBg?: string;
209+
changeBackground?: string;
216210

217211
/**
218212
* ImageKit’s in-house background removal.
219213
*/
220-
eBgRemove?: true
214+
removeBackground?: true
221215

222216
/**
223217
* Auto-enhance contrast for an image (contrast stretch).
224218
*/
225-
eContrast?: true
219+
contrastStretch?: true
226220

227221
/**
228222
* Add a drop shadow under non-transparent pixels (non-AI method). Check `eDropshadow` for AI-based shadows.
229223
* @link https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow
230224
*/
231-
eShadow?: true | string
225+
shadow?: string
232226

233227
/**
234228
* Sharpen the image or specify intensity, e.g., `e-sharpen-10`.
235229
*/
236-
eSharpen?: true | number
230+
sharpen?: true | number
237231

238232
/**
239233
* Unsharp mask for advanced sharpening, e.g., `"2-2-0.8-0.024"`.
240234
*/
241-
eUSM?: true | string;
235+
unsharpMask?: string;
242236

243237
/**
244238
* Add a linear gradient overlay. e.g.,
245239
* @link https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient
246240
*/
247-
eGradient?: true | string;
248-
249-
/**
250-
* @deprecated Use `eContrast` instead.
251-
*/
252-
effectContrast?: number | string;
253-
254-
/**
255-
* @deprecated Use `eShadow` instead.
256-
*/
257-
effectShadow?: number | string;
258-
259-
/**
260-
* @deprecated Use `eSharpen` instead.
261-
*/
262-
effectSharpen?: number | string;
263-
264-
/**
265-
* @deprecated Use `eUSM` instead.
266-
*/
267-
effectUSM?: number | string;
268-
269-
/**
270-
* @deprecated Use `eGradient` instead.
271-
*/
272-
effectGradient?: string;
273-
274-
/**
275-
* @deprecated Use `eGrayscale` instead.
276-
*/
277-
effectGray?: boolean | string;
241+
gradient?: string;
278242

279243
/**
280244
* Used to specify whether the output JPEG image must be rendered progressively. In progressive loading, the output image renders as a low-quality pixelated full image, which, over time, keeps on adding more pixels and information to the image. This helps you maintain a fast perceived load time.
281245
*/
282-
progressive?: boolean;
246+
progressiveJPEG?: boolean;
283247

284248
/**
285249
* Used to specify whether the output image (if in JPEG or PNG) must be compressed losslessly.

0 commit comments

Comments
 (0)