@imagekit/javascript 5.1.0-beta.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/dist/imagekit.cjs.js +236 -228
- package/dist/imagekit.esm.js +236 -228
- package/dist/imagekit.min.js +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/interfaces/UploadOptions.d.ts +205 -102
- package/dist/interfaces/UploadResponse.d.ts +363 -122
- package/dist/interfaces/index.d.ts +1 -2
- package/dist/interfaces/shared.d.ts +1475 -0
- package/dist/responsive.d.ts +1 -53
- package/dist/url.d.ts +1 -2
- package/package.json +1 -1
- package/dist/interfaces/SrcOptions.d.ts +0 -32
- package/dist/interfaces/Transformation.d.ts +0 -637
|
@@ -1,637 +0,0 @@
|
|
|
1
|
-
export type TransformationPosition = "path" | "query";
|
|
2
|
-
export type StreamingResolution = "240" | "360" | "480" | "720" | "1080" | "1440" | "2160";
|
|
3
|
-
/**
|
|
4
|
-
* The SDK provides easy-to-use names for transformations. These names are converted to the corresponding transformation string before being added to the URL.
|
|
5
|
-
* SDKs are updated regularly to support new transformations. If you want to use a transformation that is not supported by the SDK,
|
|
6
|
-
* You can use the `raw` parameter to pass the transformation string directly.
|
|
7
|
-
*
|
|
8
|
-
* [Transformations Documentation](https://imagekit.io/docs/transformations)
|
|
9
|
-
*/
|
|
10
|
-
export interface Transformation {
|
|
11
|
-
/**
|
|
12
|
-
* Specifies the width of the output. If a value between 0 and 1 is provided, it is treated as a percentage (e.g., `0.4` represents 40% of the original width).
|
|
13
|
-
* You can also supply arithmetic expressions (e.g., `iw_div_2`).
|
|
14
|
-
*
|
|
15
|
-
* Width transformation - [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) | [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w)
|
|
16
|
-
*/
|
|
17
|
-
width?: number | string;
|
|
18
|
-
/**
|
|
19
|
-
* Specifies the height of the output. If a value between 0 and 1 is provided, it is treated as a percentage (e.g., `0.5` represents 50% of the original height).
|
|
20
|
-
* You can also supply arithmetic expressions (e.g., `ih_mul_0.5`).
|
|
21
|
-
*
|
|
22
|
-
* Height transformation - [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) | [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h)
|
|
23
|
-
*/
|
|
24
|
-
height?: number | string;
|
|
25
|
-
/**
|
|
26
|
-
* Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with either width or height (but not both).
|
|
27
|
-
* For example: aspectRatio = `4:3`, `4_3`, or an expression like `iar_div_2`.
|
|
28
|
-
*
|
|
29
|
-
* [Image Resize and Crop - Aspect Ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar)
|
|
30
|
-
*/
|
|
31
|
-
aspectRatio?: number | string;
|
|
32
|
-
/**
|
|
33
|
-
* Specifies the background to be used in conjunction with certain cropping strategies when resizing an image.
|
|
34
|
-
* - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`.
|
|
35
|
-
*
|
|
36
|
-
* [Effects and Enhancements - Solid Color Background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background)
|
|
37
|
-
*
|
|
38
|
-
* - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc.
|
|
39
|
-
*
|
|
40
|
-
* [Effects and Enhancements - Blurred Background](https://imagekit.io/docs/effects-and-enhancements#blurred-background)
|
|
41
|
-
*
|
|
42
|
-
* - Expand the image boundaries using generative fill: `genfill`. Not supported inside overlay. Optionally, control the background scene by passing a text prompt:
|
|
43
|
-
* `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`.
|
|
44
|
-
*
|
|
45
|
-
* [AI Transformations - Generative Fill Background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill)
|
|
46
|
-
*/
|
|
47
|
-
background?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Adds a border to the output media. Accepts a string in the format `<border-width>_<hex-code>`
|
|
50
|
-
* (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`.
|
|
51
|
-
*
|
|
52
|
-
* [Effects and Enhancements - Border](https://imagekit.io/docs/effects-and-enhancements#border---b)
|
|
53
|
-
*/
|
|
54
|
-
border?: string;
|
|
55
|
-
/**
|
|
56
|
-
* [Image Resize and Crop - Crop Modes](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus)
|
|
57
|
-
*/
|
|
58
|
-
crop?: "force" | "at_max" | "at_max_enlarge" | "at_least" | "maintain_ratio";
|
|
59
|
-
/**
|
|
60
|
-
* [Image Resize and Crop - Crop Modes](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus)
|
|
61
|
-
*/
|
|
62
|
-
cropMode?: "pad_resize" | "extract" | "pad_extract";
|
|
63
|
-
/**
|
|
64
|
-
* Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) calculation.
|
|
65
|
-
*
|
|
66
|
-
* [Image Resize and Crop - DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr)
|
|
67
|
-
*/
|
|
68
|
-
dpr?: number;
|
|
69
|
-
/**
|
|
70
|
-
* This parameter can be used with pad resize, maintain ratio, or extract crop to modify the padding or cropping behavior.
|
|
71
|
-
*
|
|
72
|
-
* [Image Resize and Crop - Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo)
|
|
73
|
-
*/
|
|
74
|
-
focus?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Specifies the quality of the output image for lossy formats such as JPEG, WebP, and AVIF.
|
|
77
|
-
* A higher quality value results in a larger file size with better quality, while a lower value produces a smaller file size with reduced quality.
|
|
78
|
-
*
|
|
79
|
-
* [Image Optimization - Quality](https://imagekit.io/docs/image-optimization#quality---q)
|
|
80
|
-
*/
|
|
81
|
-
quality?: number;
|
|
82
|
-
/**
|
|
83
|
-
* [Image Resize and Crop - Focus Using Cropped Image Coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates)
|
|
84
|
-
*/
|
|
85
|
-
x?: number | string;
|
|
86
|
-
/**
|
|
87
|
-
* [Image Resize and Crop - Focus Using Cropped Image Coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates)
|
|
88
|
-
*/
|
|
89
|
-
xCenter?: number | string;
|
|
90
|
-
/**
|
|
91
|
-
* [Image Resize and Crop - Focus Using Cropped Image Coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates)
|
|
92
|
-
*/
|
|
93
|
-
y?: number | string;
|
|
94
|
-
/**
|
|
95
|
-
* [Image Resize and Crop - Focus Using Cropped Image Coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates)
|
|
96
|
-
*/
|
|
97
|
-
yCenter?: number | string;
|
|
98
|
-
/**
|
|
99
|
-
* Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, `mp4`, or `auto`.
|
|
100
|
-
* You can also pass `orig` for images to return the original format.
|
|
101
|
-
* ImageKit automatically delivers images and videos in the optimal format based on device support unless overridden by the dashboard settings or the format parameter.
|
|
102
|
-
*
|
|
103
|
-
* [Image Optimization - Format](https://imagekit.io/docs/image-optimization#format---f) & [Video Optimization - Format](https://imagekit.io/docs/video-optimization#format---f)
|
|
104
|
-
*/
|
|
105
|
-
format?: "auto" | "webp" | "jpg" | "jpeg" | "png" | "gif" | "svg" | "mp4" | "webm" | "avif" | "orig";
|
|
106
|
-
/**
|
|
107
|
-
* Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`.
|
|
108
|
-
*
|
|
109
|
-
* [Video Optimization - Video Codec](https://imagekit.io/docs/video-optimization#video-codec---vc)
|
|
110
|
-
*/
|
|
111
|
-
videoCodec?: "h264" | "vp9" | "av1" | "none";
|
|
112
|
-
/**
|
|
113
|
-
* Specifies the audio codec, e.g., `aac`, `opus`, or `none`.
|
|
114
|
-
*
|
|
115
|
-
* [Video Optimization - Audio Codec](https://imagekit.io/docs/video-optimization#audio-codec---ac)
|
|
116
|
-
*/
|
|
117
|
-
audioCodec?: "aac" | "opus" | "none";
|
|
118
|
-
/**
|
|
119
|
-
* Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular/oval shapes.
|
|
120
|
-
*
|
|
121
|
-
* [Effects and Enhancements - Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r)
|
|
122
|
-
*/
|
|
123
|
-
radius?: number | "max";
|
|
124
|
-
/**
|
|
125
|
-
* Specifies the rotation angle in degrees. Positive values rotate the image clockwise; you can also use, for example, `N40` for counterclockwise rotation
|
|
126
|
-
* or `auto` to use the orientation specified in the image's EXIF data.
|
|
127
|
-
* For videos, only the following values are supported: 0, 90, 180, 270, or 360.
|
|
128
|
-
*
|
|
129
|
-
* [Effects and Enhancements - Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt)
|
|
130
|
-
*/
|
|
131
|
-
rotation?: number | string;
|
|
132
|
-
/**
|
|
133
|
-
* Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an expression like `bl-10`.
|
|
134
|
-
*
|
|
135
|
-
* [Effects and Enhancements - Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl)
|
|
136
|
-
*/
|
|
137
|
-
blur?: number;
|
|
138
|
-
/**
|
|
139
|
-
* [Transformations - Named Transformations](https://imagekit.io/docs/transformations#named-transformations)
|
|
140
|
-
*/
|
|
141
|
-
named?: string;
|
|
142
|
-
/**
|
|
143
|
-
* Specifies a fallback image if the resource is not found, e.g., a URL or file path.
|
|
144
|
-
*
|
|
145
|
-
* [Image Transformation - Default Image](https://imagekit.io/docs/image-transformation#default-image---di)
|
|
146
|
-
*/
|
|
147
|
-
defaultImage?: string;
|
|
148
|
-
/**
|
|
149
|
-
* Flips or mirrors an image either horizontally, vertically, or both.
|
|
150
|
-
* Acceptable values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`.
|
|
151
|
-
*
|
|
152
|
-
* [Effects and Enhancements - Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl)
|
|
153
|
-
*/
|
|
154
|
-
flip?: "h" | "v" | "h_v" | "v_h";
|
|
155
|
-
/**
|
|
156
|
-
* If set to true, serves the original file without applying any transformations.
|
|
157
|
-
*
|
|
158
|
-
* [Core Delivery Features - Deliver Original File As Is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true)
|
|
159
|
-
*/
|
|
160
|
-
original?: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`.
|
|
163
|
-
* Arithmetic expressions are also supported.
|
|
164
|
-
*
|
|
165
|
-
* [Trim Videos - Start Offset](https://imagekit.io/docs/trim-videos#start-offset---so)
|
|
166
|
-
*/
|
|
167
|
-
startOffset?: number | string;
|
|
168
|
-
/**
|
|
169
|
-
* Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`.
|
|
170
|
-
* Typically used with startOffset to define a time window. Arithmetic expressions are supported.
|
|
171
|
-
*
|
|
172
|
-
* [Trim Videos - End Offset](https://imagekit.io/docs/trim-videos#end-offset---eo)
|
|
173
|
-
*/
|
|
174
|
-
endOffset?: number | string;
|
|
175
|
-
/**
|
|
176
|
-
* Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`.
|
|
177
|
-
* Typically used with startOffset to indicate the length from the start offset. Arithmetic expressions are supported.
|
|
178
|
-
*
|
|
179
|
-
* [Trim Videos - Duration](https://imagekit.io/docs/trim-videos#duration---du)
|
|
180
|
-
*/
|
|
181
|
-
duration?: number | string;
|
|
182
|
-
/**
|
|
183
|
-
* An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, `480`, `720`, `1080`].
|
|
184
|
-
*
|
|
185
|
-
* [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming)
|
|
186
|
-
*/
|
|
187
|
-
streamingResolutions?: StreamingResolution[];
|
|
188
|
-
/**
|
|
189
|
-
* Enables a grayscale effect for images.
|
|
190
|
-
*
|
|
191
|
-
* [Effects and Enhancements - Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale)
|
|
192
|
-
*/
|
|
193
|
-
grayscale?: true;
|
|
194
|
-
/**
|
|
195
|
-
* Upscales images beyond their original dimensions using AI. Not supported inside overlay.
|
|
196
|
-
*
|
|
197
|
-
* [AI Transformations - Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale)
|
|
198
|
-
*/
|
|
199
|
-
aiUpscale?: true;
|
|
200
|
-
/**
|
|
201
|
-
* Performs AI-based retouching to improve faces or product shots. Not supported inside overlay.
|
|
202
|
-
*
|
|
203
|
-
* [AI Transformations - Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch)
|
|
204
|
-
*/
|
|
205
|
-
aiRetouch?: true;
|
|
206
|
-
/**
|
|
207
|
-
* Generates a variation of an image using AI. This produces a new image with slight variations from the original,
|
|
208
|
-
* such as changes in color, texture, and other visual elements, while preserving the structure and essence of the original image. Not supported inside overlay.
|
|
209
|
-
*
|
|
210
|
-
* [AI Transformations - Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar)
|
|
211
|
-
*/
|
|
212
|
-
aiVariation?: true;
|
|
213
|
-
/**
|
|
214
|
-
* Adds an AI-based drop shadow around a foreground object on a transparent or removed background.
|
|
215
|
-
* Optionally, control the direction, elevation, and saturation of the light source (e.g., `az-45` to change light direction).
|
|
216
|
-
* Pass `true` for the default drop shadow, or provide a string for a custom drop shadow.
|
|
217
|
-
* Supported inside overlay.
|
|
218
|
-
*
|
|
219
|
-
* [AI Transformations - Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow)
|
|
220
|
-
*/
|
|
221
|
-
aiDropShadow?: true | string;
|
|
222
|
-
/**
|
|
223
|
-
* Uses AI to change the background. Provide a text prompt or a base64-encoded prompt,
|
|
224
|
-
* e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`.
|
|
225
|
-
* Not supported inside overlay.
|
|
226
|
-
*
|
|
227
|
-
* [AI Transformations - Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg)
|
|
228
|
-
*/
|
|
229
|
-
aiChangeBackground?: string;
|
|
230
|
-
/**
|
|
231
|
-
* Applies ImageKit’s in-house background removal.
|
|
232
|
-
* Supported inside overlay.
|
|
233
|
-
*
|
|
234
|
-
* [AI Transformations - Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove)
|
|
235
|
-
*/
|
|
236
|
-
aiRemoveBackground?: true;
|
|
237
|
-
/**
|
|
238
|
-
* Uses third-party background removal.
|
|
239
|
-
* Note: It is recommended to use aiRemoveBackground, ImageKit’s in-house solution, which is more cost-effective.
|
|
240
|
-
* Supported inside overlay.
|
|
241
|
-
*
|
|
242
|
-
* [AI Transformations - External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg)
|
|
243
|
-
*/
|
|
244
|
-
aiRemoveBackgroundExternal?: true;
|
|
245
|
-
/**
|
|
246
|
-
* Automatically enhances the contrast of an image (contrast stretch).
|
|
247
|
-
*
|
|
248
|
-
* [Effects and Enhancements - Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast)
|
|
249
|
-
*/
|
|
250
|
-
contrastStretch?: true;
|
|
251
|
-
/**
|
|
252
|
-
* Adds a shadow beneath solid objects in an image with a transparent background.
|
|
253
|
-
* For AI-based drop shadows, refer to aiDropShadow.
|
|
254
|
-
* Pass `true` for a default shadow, or provide a string for a custom shadow.
|
|
255
|
-
*
|
|
256
|
-
* [Effects and Enhancements - Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow)
|
|
257
|
-
*/
|
|
258
|
-
shadow?: true | string;
|
|
259
|
-
/**
|
|
260
|
-
* Sharpens the input image, highlighting edges and finer details.
|
|
261
|
-
* Pass `true` for default sharpening, or provide a numeric value for custom sharpening.
|
|
262
|
-
*
|
|
263
|
-
* [Effects and Enhancements - Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen)
|
|
264
|
-
*/
|
|
265
|
-
sharpen?: true | number;
|
|
266
|
-
/**
|
|
267
|
-
* Applies Unsharp Masking (USM), an image sharpening technique.
|
|
268
|
-
* Pass `true` for a default unsharp mask, or provide a string for a custom unsharp mask.
|
|
269
|
-
*
|
|
270
|
-
* [Effects and Enhancements - Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm)
|
|
271
|
-
*/
|
|
272
|
-
unsharpMask?: true | string;
|
|
273
|
-
/**
|
|
274
|
-
* Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a string for a custom gradient.
|
|
275
|
-
*
|
|
276
|
-
* [Effects and Enhancements - Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient)
|
|
277
|
-
*/
|
|
278
|
-
gradient?: true | string;
|
|
279
|
-
/**
|
|
280
|
-
* Specifies whether the output JPEG image should be rendered progressively. Progressive loading begins with a low-quality,
|
|
281
|
-
* pixelated version of the full image, which gradually improves to provide a faster perceived load time.
|
|
282
|
-
*
|
|
283
|
-
* [Image Optimization - Progressive Image](https://imagekit.io/docs/image-optimization#progressive-image---pr)
|
|
284
|
-
*/
|
|
285
|
-
progressive?: boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Specifies whether the output image (in JPEG or PNG) should be compressed losslessly.
|
|
288
|
-
*
|
|
289
|
-
* [Image Optimization - Lossless Compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo)
|
|
290
|
-
*/
|
|
291
|
-
lossless?: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Indicates whether the output image should retain the original color profile.
|
|
294
|
-
*
|
|
295
|
-
* [Image Optimization - Color Profile](https://imagekit.io/docs/image-optimization#color-profile---cp)
|
|
296
|
-
*/
|
|
297
|
-
colorProfile?: boolean;
|
|
298
|
-
/**
|
|
299
|
-
* By default, ImageKit removes all metadata during automatic image compression.
|
|
300
|
-
* Set this to true to preserve metadata.
|
|
301
|
-
*
|
|
302
|
-
* [Image Optimization - Image Metadata](https://imagekit.io/docs/image-optimization#image-metadata---md)
|
|
303
|
-
*/
|
|
304
|
-
metadata?: boolean;
|
|
305
|
-
/**
|
|
306
|
-
* Specifies the opacity level of the output image.
|
|
307
|
-
*
|
|
308
|
-
* [Effects and Enhancements - Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o)
|
|
309
|
-
*/
|
|
310
|
-
opacity?: number;
|
|
311
|
-
/**
|
|
312
|
-
* Useful for images with a solid or nearly solid background and a central object. This parameter trims the background,
|
|
313
|
-
* leaving only the central object in the output image.
|
|
314
|
-
*
|
|
315
|
-
* [Effects and Enhancements - Trim Edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t)
|
|
316
|
-
*/
|
|
317
|
-
trim?: true | number;
|
|
318
|
-
/**
|
|
319
|
-
* Accepts a numeric value that determines how much to zoom in or out of the cropped area.
|
|
320
|
-
* It should be used in conjunction with fo-face or fo-<object_name>.
|
|
321
|
-
*
|
|
322
|
-
* [Image Resize and Crop - Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z)
|
|
323
|
-
*/
|
|
324
|
-
zoom?: number;
|
|
325
|
-
/**
|
|
326
|
-
* Extracts a specific page or frame from multi-page or layered files (PDF, PSD, AI).
|
|
327
|
-
* For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the 2nd and 3rd layers),
|
|
328
|
-
* or by name (e.g., `name-layer-4` for a PSD layer).
|
|
329
|
-
*
|
|
330
|
-
* [Vector and Animated Images - Thumbnail Extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files)
|
|
331
|
-
*/
|
|
332
|
-
page?: number | string;
|
|
333
|
-
/**
|
|
334
|
-
* Pass any transformation not directly supported by the SDK.
|
|
335
|
-
* This transformation string is appended to the URL as provided.
|
|
336
|
-
*/
|
|
337
|
-
raw?: string;
|
|
338
|
-
/**
|
|
339
|
-
* Specifies an overlay to be applied on the parent image or video.
|
|
340
|
-
* ImageKit supports overlays including images, text, videos, subtitles, and solid colors.
|
|
341
|
-
*
|
|
342
|
-
* [Transformations - Overlay Using Layers](https://imagekit.io/docs/transformations#overlay-using-layers)
|
|
343
|
-
*/
|
|
344
|
-
overlay?: Overlay;
|
|
345
|
-
}
|
|
346
|
-
export type Overlay = TextOverlay | ImageOverlay | VideoOverlay | SubtitleOverlay | SolidColorOverlay;
|
|
347
|
-
export interface BaseOverlay {
|
|
348
|
-
/**
|
|
349
|
-
* Specifies the overlay's position relative to the parent asset.
|
|
350
|
-
* Accepts a JSON object with `x` and `y` (or `focus`) properties.
|
|
351
|
-
*
|
|
352
|
-
* [Transformations - Position of Layer](https://imagekit.io/docs/transformations#position-of-layer)
|
|
353
|
-
*/
|
|
354
|
-
position?: OverlayPosition;
|
|
355
|
-
/**
|
|
356
|
-
* Specifies timing information for the overlay (only applicable if the base asset is a video).
|
|
357
|
-
* Accepts a JSON object with `start` (`lso`), `end` (`leo`), and `duration` (`ldu`) properties.
|
|
358
|
-
*
|
|
359
|
-
* [Transformations - Position of Layer](https://imagekit.io/docs/transformations#position-of-layer)
|
|
360
|
-
*/
|
|
361
|
-
timing?: OverlayTiming;
|
|
362
|
-
}
|
|
363
|
-
export interface OverlayPosition {
|
|
364
|
-
/**
|
|
365
|
-
* Specifies the x-coordinate of the top-left corner of the base asset where the overlay's top-left corner will be positioned.
|
|
366
|
-
* It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`.
|
|
367
|
-
* Maps to `lx` in the URL.
|
|
368
|
-
*
|
|
369
|
-
* Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations)
|
|
370
|
-
*/
|
|
371
|
-
x?: number | string;
|
|
372
|
-
/**
|
|
373
|
-
* Specifies the y-coordinate of the top-left corner of the base asset where the overlay's top-left corner will be positioned.
|
|
374
|
-
* It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`.
|
|
375
|
-
* Maps to `ly` in the URL.
|
|
376
|
-
*
|
|
377
|
-
* Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations)
|
|
378
|
-
*/
|
|
379
|
-
y?: number | string;
|
|
380
|
-
/**
|
|
381
|
-
* Specifies the position of the overlay relative to the parent image or video.
|
|
382
|
-
* Acceptable values: `center`, `top`, `left`, `bottom`, `right`, `top_left`, `top_right`, `bottom_left`, or `bottom_right`.
|
|
383
|
-
* Maps to `lfo` in the URL.
|
|
384
|
-
*/
|
|
385
|
-
focus?: `center` | `top` | `left` | `bottom` | `right` | `top_left` | `top_right` | `bottom_left` | `bottom_right`;
|
|
386
|
-
}
|
|
387
|
-
export interface OverlayTiming {
|
|
388
|
-
/**
|
|
389
|
-
* Specifies the start time (in seconds) for when the overlay should appear on the base video.
|
|
390
|
-
* Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`.
|
|
391
|
-
* Applies only if the base asset is a video.
|
|
392
|
-
*
|
|
393
|
-
* Maps to `lso` in the URL.
|
|
394
|
-
*/
|
|
395
|
-
start?: number | string;
|
|
396
|
-
/**
|
|
397
|
-
* Specifies the duration (in seconds) during which the overlay should appear on the base video.
|
|
398
|
-
* Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`.
|
|
399
|
-
* Applies only if the base asset is a video.
|
|
400
|
-
*
|
|
401
|
-
* Maps to `ldu` in the URL.
|
|
402
|
-
*/
|
|
403
|
-
duration?: number | string;
|
|
404
|
-
/**
|
|
405
|
-
* Specifies the end time (in seconds) for when the overlay should disappear from the base video.
|
|
406
|
-
* If both end and duration are provided, duration is ignored.
|
|
407
|
-
* Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`.
|
|
408
|
-
* Applies only if the base asset is a video.
|
|
409
|
-
*
|
|
410
|
-
* Maps to `leo` in the URL.
|
|
411
|
-
*/
|
|
412
|
-
end?: number | string;
|
|
413
|
-
}
|
|
414
|
-
export interface TextOverlay extends BaseOverlay {
|
|
415
|
-
type: "text";
|
|
416
|
-
/**
|
|
417
|
-
* Specifies the text to be displayed in the overlay. The SDK automatically handles special characters and encoding.
|
|
418
|
-
*/
|
|
419
|
-
text: string;
|
|
420
|
-
/**
|
|
421
|
-
* Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` (base64).
|
|
422
|
-
* By default, the SDK selects the appropriate format based on the input text.
|
|
423
|
-
* To always use base64 (`ie-{base64}`), set this parameter to `base64`.
|
|
424
|
-
* To always use plain text (`i-{input}`), set it to `plain`.
|
|
425
|
-
*
|
|
426
|
-
* Regardless of the encoding method, the input text is always percent-encoded to ensure it is URL-safe.
|
|
427
|
-
*/
|
|
428
|
-
encoding?: "auto" | "plain" | "base64";
|
|
429
|
-
/**
|
|
430
|
-
* Control styling of the text overlay.
|
|
431
|
-
*/
|
|
432
|
-
transformation?: TextOverlayTransformation[];
|
|
433
|
-
}
|
|
434
|
-
export interface ImageOverlay extends BaseOverlay {
|
|
435
|
-
type: "image";
|
|
436
|
-
/**
|
|
437
|
-
* Specifies the relative path to the image used as an overlay.
|
|
438
|
-
*/
|
|
439
|
-
input: string;
|
|
440
|
-
/**
|
|
441
|
-
* The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`.
|
|
442
|
-
* By default, the SDK determines the appropriate format automatically.
|
|
443
|
-
* To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`.
|
|
444
|
-
* To always use plain text (`i-{input}`), set it to `plain`.
|
|
445
|
-
*
|
|
446
|
-
* Regardless of the encoding method:
|
|
447
|
-
* - Leading and trailing slashes are removed.
|
|
448
|
-
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
449
|
-
*/
|
|
450
|
-
encoding?: "auto" | "plain" | "base64";
|
|
451
|
-
/**
|
|
452
|
-
* Array of transformations to be applied to the overlay image. Supported transformations depends on the base/parent asset.
|
|
453
|
-
*
|
|
454
|
-
* [Image](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) | [Video](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay)
|
|
455
|
-
*/
|
|
456
|
-
transformation?: Transformation[];
|
|
457
|
-
}
|
|
458
|
-
export interface VideoOverlay extends BaseOverlay {
|
|
459
|
-
type: "video";
|
|
460
|
-
/**
|
|
461
|
-
* Specifies the relative path to the video used as an overlay.
|
|
462
|
-
*/
|
|
463
|
-
input: string;
|
|
464
|
-
/**
|
|
465
|
-
* The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`.
|
|
466
|
-
* By default, the SDK determines the appropriate format automatically.
|
|
467
|
-
* To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`.
|
|
468
|
-
* To always use plain text (`i-{input}`), set it to `plain`.
|
|
469
|
-
*
|
|
470
|
-
* Regardless of the encoding method:
|
|
471
|
-
* - Leading and trailing slashes are removed.
|
|
472
|
-
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
473
|
-
*/
|
|
474
|
-
encoding?: "auto" | "plain" | "base64";
|
|
475
|
-
/**
|
|
476
|
-
* Array of transformation to be applied to the overlay video. Except `streamingResolutions`, all other video transformations are supported.
|
|
477
|
-
*
|
|
478
|
-
* [Video Transformations](https://imagekit.io/docs/video-transformation)
|
|
479
|
-
*/
|
|
480
|
-
transformation?: Transformation[];
|
|
481
|
-
}
|
|
482
|
-
export interface SubtitleOverlay extends BaseOverlay {
|
|
483
|
-
type: "subtitle";
|
|
484
|
-
/**
|
|
485
|
-
* Specifies the relative path to the subtitle file used as an overlay.
|
|
486
|
-
*/
|
|
487
|
-
input: string;
|
|
488
|
-
/**
|
|
489
|
-
* The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`.
|
|
490
|
-
* By default, the SDK determines the appropriate format automatically.
|
|
491
|
-
* To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`.
|
|
492
|
-
* To always use plain text (`i-{input}`), set it to `plain`.
|
|
493
|
-
*
|
|
494
|
-
* Regardless of the encoding method:
|
|
495
|
-
* - Leading and trailing slashes are removed.
|
|
496
|
-
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
497
|
-
*/
|
|
498
|
-
encoding?: "auto" | "plain" | "base64";
|
|
499
|
-
/**
|
|
500
|
-
* Control styling of the subtitle.
|
|
501
|
-
*
|
|
502
|
-
* [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
|
|
503
|
-
*/
|
|
504
|
-
transformation?: SubtitleOverlayTransformation[];
|
|
505
|
-
}
|
|
506
|
-
export interface SolidColorOverlay extends BaseOverlay {
|
|
507
|
-
type: "solidColor";
|
|
508
|
-
/**
|
|
509
|
-
* Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`).
|
|
510
|
-
* If an 8-character value is provided, the last two characters represent the opacity level (from `00` for 0.00 to `99` for 0.99).
|
|
511
|
-
*/
|
|
512
|
-
color: string;
|
|
513
|
-
/**
|
|
514
|
-
* Control width and height of the solid color overlay. Supported transformations depend on the base/parent asset.
|
|
515
|
-
*
|
|
516
|
-
* [Image](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) | [Video](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay)
|
|
517
|
-
*/
|
|
518
|
-
transformation?: SolidColorOverlayTransformation[];
|
|
519
|
-
}
|
|
520
|
-
export type TextOverlayTransformation = {
|
|
521
|
-
/**
|
|
522
|
-
* Specifies the maximum width (in pixels) of the overlaid text. The text wraps automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are supported. Useful when used in conjunction with the `background`.
|
|
523
|
-
*/
|
|
524
|
-
width?: number | string;
|
|
525
|
-
/**
|
|
526
|
-
* Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression.
|
|
527
|
-
*/
|
|
528
|
-
fontSize?: number | string;
|
|
529
|
-
/**
|
|
530
|
-
* Specifies the font family of the overlaid text. Choose from the [supported fonts list](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) or use a [custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay).
|
|
531
|
-
*/
|
|
532
|
-
fontFamily?: string;
|
|
533
|
-
/**
|
|
534
|
-
* Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name.
|
|
535
|
-
*/
|
|
536
|
-
fontColor?: string;
|
|
537
|
-
/**
|
|
538
|
-
* Specifies the inner alignment of the text when width is more than the text length.
|
|
539
|
-
* Supported values: `left`, `right`, and `center` (default).
|
|
540
|
-
*/
|
|
541
|
-
innerAlignment?: "left" | "right" | "center";
|
|
542
|
-
/**
|
|
543
|
-
* Specifies the padding around the overlaid text.
|
|
544
|
-
* Can be provided as a single positive integer or multiple values separated by underscores (following CSS shorthand order).
|
|
545
|
-
* Arithmetic expressions are also accepted.
|
|
546
|
-
*/
|
|
547
|
-
padding?: number | string;
|
|
548
|
-
/**
|
|
549
|
-
* Specifies the transparency level of the text overlay. Accepts integers from `1` to `9`.
|
|
550
|
-
*/
|
|
551
|
-
alpha?: number;
|
|
552
|
-
/**
|
|
553
|
-
* Specifies the typography style of the text.
|
|
554
|
-
* Supported values: `b` for bold, `i` for italics, and `b_i` for bold with italics.
|
|
555
|
-
*/
|
|
556
|
-
typography?: "b" | "i" | "b_i";
|
|
557
|
-
/**
|
|
558
|
-
* Specifies the background color of the text overlay.
|
|
559
|
-
* Accepts an RGB hex code, an RGBA code, or a color name.
|
|
560
|
-
*/
|
|
561
|
-
background?: string;
|
|
562
|
-
/**
|
|
563
|
-
* Specifies the corner radius of the text overlay.
|
|
564
|
-
* Set to `max` to achieve a circular or oval shape.
|
|
565
|
-
*/
|
|
566
|
-
radius?: number | "max";
|
|
567
|
-
/**
|
|
568
|
-
* Specifies the rotation angle of the text overlay.
|
|
569
|
-
* Accepts a numeric value for clockwise rotation or a string prefixed with "N" for counter-clockwise rotation.
|
|
570
|
-
*/
|
|
571
|
-
rotation?: number | string;
|
|
572
|
-
/**
|
|
573
|
-
* Flip/mirror the text horizontally, vertically, or in both directions.
|
|
574
|
-
* Acceptable values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`.
|
|
575
|
-
*/
|
|
576
|
-
flip?: "h" | "v" | "h_v" | "v_h";
|
|
577
|
-
/**
|
|
578
|
-
* Specifies the line height for multi-line text overlays. It will come into effect only if the text wraps over multiple lines.
|
|
579
|
-
* Accepts either an integer value or an arithmetic expression.
|
|
580
|
-
*/
|
|
581
|
-
lineHeight?: number | string;
|
|
582
|
-
};
|
|
583
|
-
export type SubtitleOverlayTransformation = {
|
|
584
|
-
/**
|
|
585
|
-
* Specifies the subtitle background color using a standard color name, an RGB color code (e.g., `FF0000`), or an RGBA color code (e.g., `FFAABB50`).
|
|
586
|
-
*/
|
|
587
|
-
background?: string;
|
|
588
|
-
/**
|
|
589
|
-
* Sets the font size of subtitle text.
|
|
590
|
-
*/
|
|
591
|
-
fontSize?: number | string;
|
|
592
|
-
/**
|
|
593
|
-
* Sets the font family of subtitle text.
|
|
594
|
-
* Refer to the [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) in the ImageKit transformations guide.
|
|
595
|
-
*/
|
|
596
|
-
fontFamily?: string;
|
|
597
|
-
/**
|
|
598
|
-
* Sets the font color of the subtitle text using a standard color name, an RGB color code (e.g., `FF0000`), or an RGBA color code (e.g., `FFAABB50`).
|
|
599
|
-
*/
|
|
600
|
-
color?: string;
|
|
601
|
-
/**
|
|
602
|
-
* Sets the typography style of the subtitle text.
|
|
603
|
-
* Supported values: `b` for bold, `i` for italics, and `b_i` for bold with italics.
|
|
604
|
-
*/
|
|
605
|
-
typography?: "b" | "i" | "b_i";
|
|
606
|
-
/**
|
|
607
|
-
* Sets the font outline of the subtitle text.
|
|
608
|
-
* Requires the outline width (an integer) and the outline color (as an RGB color code, RGBA color code, or standard web color name) separated by an underscore.
|
|
609
|
-
* Examples: `2_blue`, `2_A1CCDD`, or `2_A1CCDD50`.
|
|
610
|
-
*/
|
|
611
|
-
fontOutline?: string;
|
|
612
|
-
/**
|
|
613
|
-
* Sets the font shadow for the subtitle text.
|
|
614
|
-
* Requires the shadow color (as an RGB color code, RGBA color code, or standard web color name) and the shadow indent (an integer) separated by an underscore.
|
|
615
|
-
* Examples: `blue_2`, `A1CCDD_3`, or `A1CCDD50_3`.
|
|
616
|
-
*/
|
|
617
|
-
fontShadow?: string;
|
|
618
|
-
};
|
|
619
|
-
export type SolidColorOverlayTransformation = Pick<Transformation, "width" | "height" | "radius"> & {
|
|
620
|
-
/**
|
|
621
|
-
* Specifies the transparency level of the overlaid solid color layer. Supports integers from `1` to `9`.
|
|
622
|
-
*/
|
|
623
|
-
alpha?: number;
|
|
624
|
-
/**
|
|
625
|
-
* Specifies the background color of the solid color overlay.
|
|
626
|
-
* Accepts an RGB hex code, an RGBA code, or a color name.
|
|
627
|
-
*/
|
|
628
|
-
background?: string;
|
|
629
|
-
/**
|
|
630
|
-
* Only works if base asset is an image.
|
|
631
|
-
*
|
|
632
|
-
* Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a string for a custom gradient.
|
|
633
|
-
*
|
|
634
|
-
* [Effects and Enhancements - Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient)
|
|
635
|
-
*/
|
|
636
|
-
gradient?: Transformation["gradient"];
|
|
637
|
-
};
|