@imagekit/javascript 5.1.0 → 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.
@@ -0,0 +1,1475 @@
1
+ export interface BaseOverlay {
2
+ /**
3
+ * Controls how the layer blends with the base image or underlying content. Maps to
4
+ * `lm` in the URL. By default, layers completely cover the base image beneath
5
+ * them. Layer modes change this behavior:
6
+ *
7
+ * - `multiply`: Multiplies the pixel values of the layer with the base image. The
8
+ * result is always darker than the original images. This is ideal for applying
9
+ * shadows or color tints.
10
+ * - `displace`: Uses the layer as a displacement map to distort pixels in the base
11
+ * image. The red channel controls horizontal displacement, and the green channel
12
+ * controls vertical displacement. Requires `x` or `y` parameter to control
13
+ * displacement magnitude.
14
+ * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the
15
+ * base image transparent, while transparent areas leave the base image
16
+ * unchanged. This mode functions like a hole-punch, effectively cutting the
17
+ * shape of the layer out of the underlying image.
18
+ * - `cutter`: Acts as a shape mask where only the parts of the base image that
19
+ * fall inside the opaque area of the layer are preserved. This mode functions
20
+ * like a cookie-cutter, trimming the base image to match the specific dimensions
21
+ * and shape of the layer. See
22
+ * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes).
23
+ */
24
+ layerMode?: 'multiply' | 'cutter' | 'cutout' | 'displace';
25
+ /**
26
+ * Specifies the overlay's position relative to the parent asset. See
27
+ * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer).
28
+ */
29
+ position?: OverlayPosition;
30
+ /**
31
+ * Specifies timing information for the overlay (only applicable if the base asset
32
+ * is a video). See
33
+ * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer).
34
+ */
35
+ timing?: OverlayTiming;
36
+ }
37
+ /**
38
+ * Configuration object for an extension (base extensions only, not saved extension
39
+ * references).
40
+ */
41
+ export type ExtensionConfig = ExtensionConfig.RemoveBg | ExtensionConfig.AutoTaggingExtension | ExtensionConfig.AIAutoDescription | ExtensionConfig.AITasks;
42
+ export declare namespace ExtensionConfig {
43
+ interface RemoveBg {
44
+ /**
45
+ * Specifies the background removal extension.
46
+ */
47
+ name: 'remove-bg';
48
+ options?: RemoveBg.Options;
49
+ }
50
+ namespace RemoveBg {
51
+ interface Options {
52
+ /**
53
+ * Whether to add an artificial shadow to the result. Default is false. Note:
54
+ * Adding shadows is currently only supported for car photos.
55
+ */
56
+ add_shadow?: boolean;
57
+ /**
58
+ * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or
59
+ * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be
60
+ * empty.
61
+ */
62
+ bg_color?: string;
63
+ /**
64
+ * Sets a background image from a URL. If this parameter is set, `bg_color` must be
65
+ * empty.
66
+ */
67
+ bg_image_url?: string;
68
+ /**
69
+ * Allows semi-transparent regions in the result. Default is true. Note:
70
+ * Semitransparency is currently only supported for car windows.
71
+ */
72
+ semitransparency?: boolean;
73
+ }
74
+ }
75
+ interface AutoTaggingExtension {
76
+ /**
77
+ * Maximum number of tags to attach to the asset.
78
+ */
79
+ maxTags: number;
80
+ /**
81
+ * Minimum confidence level for tags to be considered valid.
82
+ */
83
+ minConfidence: number;
84
+ /**
85
+ * Specifies the auto-tagging extension used.
86
+ */
87
+ name: 'google-auto-tagging' | 'aws-auto-tagging';
88
+ }
89
+ interface AIAutoDescription {
90
+ /**
91
+ * Specifies the auto description extension.
92
+ */
93
+ name: 'ai-auto-description';
94
+ }
95
+ interface AITasks {
96
+ /**
97
+ * Specifies the AI tasks extension for automated image analysis using AI models.
98
+ */
99
+ name: 'ai-tasks';
100
+ /**
101
+ * Array of task objects defining AI operations to perform on the asset.
102
+ */
103
+ tasks: Array<AITasks.SelectTags | AITasks.SelectMetadata | AITasks.YesNo>;
104
+ }
105
+ namespace AITasks {
106
+ interface SelectTags {
107
+ /**
108
+ * The question or instruction for the AI to analyze the image.
109
+ */
110
+ instruction: string;
111
+ /**
112
+ * Task type that analyzes the image and adds matching tags from a vocabulary.
113
+ */
114
+ type: 'select_tags';
115
+ /**
116
+ * Array of possible tag values. Combined length of all strings must not exceed 500
117
+ * characters. Cannot contain the `%` character.
118
+ */
119
+ vocabulary: Array<string>;
120
+ /**
121
+ * Maximum number of tags to select from the vocabulary.
122
+ */
123
+ max_selections?: number;
124
+ /**
125
+ * Minimum number of tags to select from the vocabulary.
126
+ */
127
+ min_selections?: number;
128
+ }
129
+ interface SelectMetadata {
130
+ /**
131
+ * Name of the custom metadata field to set. The field must exist in your account.
132
+ */
133
+ field: string;
134
+ /**
135
+ * The question or instruction for the AI to analyze the image.
136
+ */
137
+ instruction: string;
138
+ /**
139
+ * Task type that analyzes the image and sets a custom metadata field value from a
140
+ * vocabulary.
141
+ */
142
+ type: 'select_metadata';
143
+ /**
144
+ * Maximum number of values to select from the vocabulary.
145
+ */
146
+ max_selections?: number;
147
+ /**
148
+ * Minimum number of values to select from the vocabulary.
149
+ */
150
+ min_selections?: number;
151
+ /**
152
+ * Array of possible values matching the custom metadata field type.
153
+ */
154
+ vocabulary?: Array<string | number | boolean>;
155
+ }
156
+ interface YesNo {
157
+ /**
158
+ * The yes/no question for the AI to answer about the image.
159
+ */
160
+ instruction: string;
161
+ /**
162
+ * Task type that asks a yes/no question and executes actions based on the answer.
163
+ */
164
+ type: 'yes_no';
165
+ /**
166
+ * Actions to execute if the AI answers no.
167
+ */
168
+ on_no?: YesNo.OnNo;
169
+ /**
170
+ * Actions to execute if the AI cannot determine the answer.
171
+ */
172
+ on_unknown?: YesNo.OnUnknown;
173
+ /**
174
+ * Actions to execute if the AI answers yes.
175
+ */
176
+ on_yes?: YesNo.OnYes;
177
+ }
178
+ namespace YesNo {
179
+ /**
180
+ * Actions to execute if the AI answers no.
181
+ */
182
+ interface OnNo {
183
+ /**
184
+ * Array of tag strings to add to the asset.
185
+ */
186
+ add_tags?: Array<string>;
187
+ /**
188
+ * Array of tag strings to remove from the asset.
189
+ */
190
+ remove_tags?: Array<string>;
191
+ /**
192
+ * Array of custom metadata field updates.
193
+ */
194
+ set_metadata?: Array<OnNo.SetMetadata>;
195
+ /**
196
+ * Array of custom metadata fields to remove.
197
+ */
198
+ unset_metadata?: Array<OnNo.UnsetMetadata>;
199
+ }
200
+ namespace OnNo {
201
+ interface SetMetadata {
202
+ /**
203
+ * Name of the custom metadata field to set.
204
+ */
205
+ field: string;
206
+ /**
207
+ * Value to set for the custom metadata field. The value type should match the
208
+ * custom metadata field type.
209
+ */
210
+ value: string | number | boolean | Array<string | number | boolean>;
211
+ }
212
+ interface UnsetMetadata {
213
+ /**
214
+ * Name of the custom metadata field to remove.
215
+ */
216
+ field: string;
217
+ }
218
+ }
219
+ /**
220
+ * Actions to execute if the AI cannot determine the answer.
221
+ */
222
+ interface OnUnknown {
223
+ /**
224
+ * Array of tag strings to add to the asset.
225
+ */
226
+ add_tags?: Array<string>;
227
+ /**
228
+ * Array of tag strings to remove from the asset.
229
+ */
230
+ remove_tags?: Array<string>;
231
+ /**
232
+ * Array of custom metadata field updates.
233
+ */
234
+ set_metadata?: Array<OnUnknown.SetMetadata>;
235
+ /**
236
+ * Array of custom metadata fields to remove.
237
+ */
238
+ unset_metadata?: Array<OnUnknown.UnsetMetadata>;
239
+ }
240
+ namespace OnUnknown {
241
+ interface SetMetadata {
242
+ /**
243
+ * Name of the custom metadata field to set.
244
+ */
245
+ field: string;
246
+ /**
247
+ * Value to set for the custom metadata field. The value type should match the
248
+ * custom metadata field type.
249
+ */
250
+ value: string | number | boolean | Array<string | number | boolean>;
251
+ }
252
+ interface UnsetMetadata {
253
+ /**
254
+ * Name of the custom metadata field to remove.
255
+ */
256
+ field: string;
257
+ }
258
+ }
259
+ /**
260
+ * Actions to execute if the AI answers yes.
261
+ */
262
+ interface OnYes {
263
+ /**
264
+ * Array of tag strings to add to the asset.
265
+ */
266
+ add_tags?: Array<string>;
267
+ /**
268
+ * Array of tag strings to remove from the asset.
269
+ */
270
+ remove_tags?: Array<string>;
271
+ /**
272
+ * Array of custom metadata field updates.
273
+ */
274
+ set_metadata?: Array<OnYes.SetMetadata>;
275
+ /**
276
+ * Array of custom metadata fields to remove.
277
+ */
278
+ unset_metadata?: Array<OnYes.UnsetMetadata>;
279
+ }
280
+ namespace OnYes {
281
+ interface SetMetadata {
282
+ /**
283
+ * Name of the custom metadata field to set.
284
+ */
285
+ field: string;
286
+ /**
287
+ * Value to set for the custom metadata field. The value type should match the
288
+ * custom metadata field type.
289
+ */
290
+ value: string | number | boolean | Array<string | number | boolean>;
291
+ }
292
+ interface UnsetMetadata {
293
+ /**
294
+ * Name of the custom metadata field to remove.
295
+ */
296
+ field: string;
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ /**
303
+ * Array of extensions to be applied to the asset. Each extension can be configured
304
+ * with specific parameters based on the extension type.
305
+ */
306
+ export type Extensions = Array<Extensions.RemoveBg | Extensions.AutoTaggingExtension | Extensions.AIAutoDescription | Extensions.AITasks | Extensions.SavedExtension>;
307
+ export declare namespace Extensions {
308
+ interface RemoveBg {
309
+ /**
310
+ * Specifies the background removal extension.
311
+ */
312
+ name: 'remove-bg';
313
+ options?: RemoveBg.Options;
314
+ }
315
+ namespace RemoveBg {
316
+ interface Options {
317
+ /**
318
+ * Whether to add an artificial shadow to the result. Default is false. Note:
319
+ * Adding shadows is currently only supported for car photos.
320
+ */
321
+ add_shadow?: boolean;
322
+ /**
323
+ * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or
324
+ * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be
325
+ * empty.
326
+ */
327
+ bg_color?: string;
328
+ /**
329
+ * Sets a background image from a URL. If this parameter is set, `bg_color` must be
330
+ * empty.
331
+ */
332
+ bg_image_url?: string;
333
+ /**
334
+ * Allows semi-transparent regions in the result. Default is true. Note:
335
+ * Semitransparency is currently only supported for car windows.
336
+ */
337
+ semitransparency?: boolean;
338
+ }
339
+ }
340
+ interface AutoTaggingExtension {
341
+ /**
342
+ * Maximum number of tags to attach to the asset.
343
+ */
344
+ maxTags: number;
345
+ /**
346
+ * Minimum confidence level for tags to be considered valid.
347
+ */
348
+ minConfidence: number;
349
+ /**
350
+ * Specifies the auto-tagging extension used.
351
+ */
352
+ name: 'google-auto-tagging' | 'aws-auto-tagging';
353
+ }
354
+ interface AIAutoDescription {
355
+ /**
356
+ * Specifies the auto description extension.
357
+ */
358
+ name: 'ai-auto-description';
359
+ }
360
+ interface AITasks {
361
+ /**
362
+ * Specifies the AI tasks extension for automated image analysis using AI models.
363
+ */
364
+ name: 'ai-tasks';
365
+ /**
366
+ * Array of task objects defining AI operations to perform on the asset.
367
+ */
368
+ tasks: Array<AITasks.SelectTags | AITasks.SelectMetadata | AITasks.YesNo>;
369
+ }
370
+ namespace AITasks {
371
+ interface SelectTags {
372
+ /**
373
+ * The question or instruction for the AI to analyze the image.
374
+ */
375
+ instruction: string;
376
+ /**
377
+ * Task type that analyzes the image and adds matching tags from a vocabulary.
378
+ */
379
+ type: 'select_tags';
380
+ /**
381
+ * Array of possible tag values. Combined length of all strings must not exceed 500
382
+ * characters. Cannot contain the `%` character.
383
+ */
384
+ vocabulary: Array<string>;
385
+ /**
386
+ * Maximum number of tags to select from the vocabulary.
387
+ */
388
+ max_selections?: number;
389
+ /**
390
+ * Minimum number of tags to select from the vocabulary.
391
+ */
392
+ min_selections?: number;
393
+ }
394
+ interface SelectMetadata {
395
+ /**
396
+ * Name of the custom metadata field to set. The field must exist in your account.
397
+ */
398
+ field: string;
399
+ /**
400
+ * The question or instruction for the AI to analyze the image.
401
+ */
402
+ instruction: string;
403
+ /**
404
+ * Task type that analyzes the image and sets a custom metadata field value from a
405
+ * vocabulary.
406
+ */
407
+ type: 'select_metadata';
408
+ /**
409
+ * Maximum number of values to select from the vocabulary.
410
+ */
411
+ max_selections?: number;
412
+ /**
413
+ * Minimum number of values to select from the vocabulary.
414
+ */
415
+ min_selections?: number;
416
+ /**
417
+ * Array of possible values matching the custom metadata field type.
418
+ */
419
+ vocabulary?: Array<string | number | boolean>;
420
+ }
421
+ interface YesNo {
422
+ /**
423
+ * The yes/no question for the AI to answer about the image.
424
+ */
425
+ instruction: string;
426
+ /**
427
+ * Task type that asks a yes/no question and executes actions based on the answer.
428
+ */
429
+ type: 'yes_no';
430
+ /**
431
+ * Actions to execute if the AI answers no.
432
+ */
433
+ on_no?: YesNo.OnNo;
434
+ /**
435
+ * Actions to execute if the AI cannot determine the answer.
436
+ */
437
+ on_unknown?: YesNo.OnUnknown;
438
+ /**
439
+ * Actions to execute if the AI answers yes.
440
+ */
441
+ on_yes?: YesNo.OnYes;
442
+ }
443
+ namespace YesNo {
444
+ /**
445
+ * Actions to execute if the AI answers no.
446
+ */
447
+ interface OnNo {
448
+ /**
449
+ * Array of tag strings to add to the asset.
450
+ */
451
+ add_tags?: Array<string>;
452
+ /**
453
+ * Array of tag strings to remove from the asset.
454
+ */
455
+ remove_tags?: Array<string>;
456
+ /**
457
+ * Array of custom metadata field updates.
458
+ */
459
+ set_metadata?: Array<OnNo.SetMetadata>;
460
+ /**
461
+ * Array of custom metadata fields to remove.
462
+ */
463
+ unset_metadata?: Array<OnNo.UnsetMetadata>;
464
+ }
465
+ namespace OnNo {
466
+ interface SetMetadata {
467
+ /**
468
+ * Name of the custom metadata field to set.
469
+ */
470
+ field: string;
471
+ /**
472
+ * Value to set for the custom metadata field. The value type should match the
473
+ * custom metadata field type.
474
+ */
475
+ value: string | number | boolean | Array<string | number | boolean>;
476
+ }
477
+ interface UnsetMetadata {
478
+ /**
479
+ * Name of the custom metadata field to remove.
480
+ */
481
+ field: string;
482
+ }
483
+ }
484
+ /**
485
+ * Actions to execute if the AI cannot determine the answer.
486
+ */
487
+ interface OnUnknown {
488
+ /**
489
+ * Array of tag strings to add to the asset.
490
+ */
491
+ add_tags?: Array<string>;
492
+ /**
493
+ * Array of tag strings to remove from the asset.
494
+ */
495
+ remove_tags?: Array<string>;
496
+ /**
497
+ * Array of custom metadata field updates.
498
+ */
499
+ set_metadata?: Array<OnUnknown.SetMetadata>;
500
+ /**
501
+ * Array of custom metadata fields to remove.
502
+ */
503
+ unset_metadata?: Array<OnUnknown.UnsetMetadata>;
504
+ }
505
+ namespace OnUnknown {
506
+ interface SetMetadata {
507
+ /**
508
+ * Name of the custom metadata field to set.
509
+ */
510
+ field: string;
511
+ /**
512
+ * Value to set for the custom metadata field. The value type should match the
513
+ * custom metadata field type.
514
+ */
515
+ value: string | number | boolean | Array<string | number | boolean>;
516
+ }
517
+ interface UnsetMetadata {
518
+ /**
519
+ * Name of the custom metadata field to remove.
520
+ */
521
+ field: string;
522
+ }
523
+ }
524
+ /**
525
+ * Actions to execute if the AI answers yes.
526
+ */
527
+ interface OnYes {
528
+ /**
529
+ * Array of tag strings to add to the asset.
530
+ */
531
+ add_tags?: Array<string>;
532
+ /**
533
+ * Array of tag strings to remove from the asset.
534
+ */
535
+ remove_tags?: Array<string>;
536
+ /**
537
+ * Array of custom metadata field updates.
538
+ */
539
+ set_metadata?: Array<OnYes.SetMetadata>;
540
+ /**
541
+ * Array of custom metadata fields to remove.
542
+ */
543
+ unset_metadata?: Array<OnYes.UnsetMetadata>;
544
+ }
545
+ namespace OnYes {
546
+ interface SetMetadata {
547
+ /**
548
+ * Name of the custom metadata field to set.
549
+ */
550
+ field: string;
551
+ /**
552
+ * Value to set for the custom metadata field. The value type should match the
553
+ * custom metadata field type.
554
+ */
555
+ value: string | number | boolean | Array<string | number | boolean>;
556
+ }
557
+ interface UnsetMetadata {
558
+ /**
559
+ * Name of the custom metadata field to remove.
560
+ */
561
+ field: string;
562
+ }
563
+ }
564
+ }
565
+ }
566
+ interface SavedExtension {
567
+ /**
568
+ * The unique ID of the saved extension to apply.
569
+ */
570
+ id: string;
571
+ /**
572
+ * Indicates this is a reference to a saved extension.
573
+ */
574
+ name: 'saved-extension';
575
+ }
576
+ }
577
+ /**
578
+ * Options for generating responsive image attributes including `src`, `srcSet`,
579
+ * and `sizes` for HTML `<img>` elements. This schema extends `SrcOptions` to add
580
+ * support for responsive image generation with breakpoints.
581
+ */
582
+ export interface GetImageAttributesOptions extends SrcOptions {
583
+ /**
584
+ * Custom list of **device-width breakpoints** in pixels. These define common
585
+ * screen widths for responsive image generation.
586
+ *
587
+ * Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted
588
+ * automatically.
589
+ */
590
+ deviceBreakpoints?: Array<number>;
591
+ /**
592
+ * Custom list of **image-specific breakpoints** in pixels. Useful for generating
593
+ * small variants (e.g., placeholders or thumbnails).
594
+ *
595
+ * Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to
596
+ * `[16, 32, 48, 64, 96, 128, 256, 384]`. Sorted automatically.
597
+ */
598
+ imageBreakpoints?: Array<number>;
599
+ /**
600
+ * The value for the HTML `sizes` attribute (e.g., `"100vw"` or
601
+ * `"(min-width:768px) 50vw, 100vw"`).
602
+ *
603
+ * - If it includes one or more `vw` units, breakpoints smaller than the
604
+ * corresponding percentage of the smallest device width are excluded.
605
+ * - If it contains no `vw` units, the full breakpoint list is used.
606
+ *
607
+ * Enables a width-based strategy and generates `w` descriptors in `srcSet`.
608
+ */
609
+ sizes?: string;
610
+ /**
611
+ * The intended display width of the image in pixels, used **only when the `sizes`
612
+ * attribute is not provided**.
613
+ *
614
+ * Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors
615
+ * in `srcSet`.
616
+ *
617
+ * Ignored if `sizes` is present.
618
+ */
619
+ width?: number;
620
+ }
621
+ export interface ImageOverlay extends BaseOverlay {
622
+ /**
623
+ * Specifies the relative path to the image used as an overlay.
624
+ */
625
+ input: string;
626
+ type: 'image';
627
+ /**
628
+ * The input path can be included in the layer as either `i-{input}` or
629
+ * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate
630
+ * format automatically. To always use base64 encoding (`ie-{base64}`), set this
631
+ * parameter to `base64`. To always use plain text (`i-{input}`), set it to
632
+ * `plain`.
633
+ *
634
+ * Regardless of the encoding method:
635
+ *
636
+ * - Leading and trailing slashes are removed.
637
+ * - Remaining slashes within the path are replaced with `@@` when using plain
638
+ * text.
639
+ */
640
+ encoding?: 'auto' | 'plain' | 'base64';
641
+ /**
642
+ * Array of transformations to be applied to the overlay image. Supported
643
+ * transformations depends on the base/parent asset. See overlays on
644
+ * [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers)
645
+ * and
646
+ * [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay).
647
+ */
648
+ transformation?: Array<Transformation>;
649
+ }
650
+ /**
651
+ * Specifies an overlay to be applied on the parent image or video. ImageKit
652
+ * supports overlays including images, text, videos, subtitles, and solid colors.
653
+ * See
654
+ * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers).
655
+ */
656
+ export type Overlay = TextOverlay | ImageOverlay | VideoOverlay | SubtitleOverlay | SolidColorOverlay;
657
+ export interface OverlayPosition {
658
+ /**
659
+ * Specifies the position of the overlay relative to the parent image or video.
660
+ * Maps to `lfo` in the URL.
661
+ */
662
+ focus?: 'center' | 'top' | 'left' | 'bottom' | 'right' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right';
663
+ /**
664
+ * Specifies the x-coordinate of the top-left corner of the base asset where the
665
+ * overlay's top-left corner will be positioned. It also accepts arithmetic
666
+ * expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn
667
+ * about
668
+ * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations).
669
+ */
670
+ x?: number | string;
671
+ /**
672
+ * Specifies the y-coordinate of the top-left corner of the base asset where the
673
+ * overlay's top-left corner will be positioned. It also accepts arithmetic
674
+ * expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn
675
+ * about
676
+ * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations).
677
+ */
678
+ y?: number | string;
679
+ }
680
+ export interface OverlayTiming {
681
+ /**
682
+ * Specifies the duration (in seconds) during which the overlay should appear on
683
+ * the base video. Accepts a positive number up to two decimal places (e.g., `20`
684
+ * or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`.
685
+ * Applies only if the base asset is a video. Maps to `ldu` in the URL.
686
+ */
687
+ duration?: number | string;
688
+ /**
689
+ * Specifies the end time (in seconds) for when the overlay should disappear from
690
+ * the base video. If both end and duration are provided, duration is ignored.
691
+ * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and
692
+ * arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if
693
+ * the base asset is a video. Maps to `leo` in the URL.
694
+ */
695
+ end?: number | string;
696
+ /**
697
+ * Specifies the start time (in seconds) for when the overlay should appear on the
698
+ * base video. Accepts a positive number up to two decimal places (e.g., `20` or
699
+ * `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`.
700
+ * Applies only if the base asset is a video. Maps to `lso` in the URL.
701
+ */
702
+ start?: number | string;
703
+ }
704
+ /**
705
+ * Resulting set of attributes suitable for an HTML `<img>` element. Useful for
706
+ * enabling responsive image loading with `srcSet` and `sizes`.
707
+ */
708
+ export interface ResponsiveImageAttributes {
709
+ /**
710
+ * URL for the _largest_ candidate (assigned to plain `src`).
711
+ */
712
+ src: string;
713
+ /**
714
+ * `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes`
715
+ * attribute.
716
+ */
717
+ sizes?: string;
718
+ /**
719
+ * Candidate set with `w` or `x` descriptors. Multiple image URLs separated by
720
+ * commas, each with a descriptor.
721
+ */
722
+ srcSet?: string;
723
+ /**
724
+ * Width as a number (if `width` was provided in the input options).
725
+ */
726
+ width?: number;
727
+ }
728
+ /**
729
+ * Saved extension object containing extension configuration.
730
+ */
731
+ export interface SavedExtension {
732
+ /**
733
+ * Unique identifier of the saved extension.
734
+ */
735
+ id?: string;
736
+ /**
737
+ * Configuration object for an extension (base extensions only, not saved extension
738
+ * references).
739
+ */
740
+ config?: ExtensionConfig;
741
+ /**
742
+ * Timestamp when the saved extension was created.
743
+ */
744
+ createdAt?: string;
745
+ /**
746
+ * Description of the saved extension.
747
+ */
748
+ description?: string;
749
+ /**
750
+ * Name of the saved extension.
751
+ */
752
+ name?: string;
753
+ /**
754
+ * Timestamp when the saved extension was last updated.
755
+ */
756
+ updatedAt?: string;
757
+ }
758
+ export interface SolidColorOverlay extends BaseOverlay {
759
+ /**
760
+ * Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA
761
+ * code (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character value
762
+ * is provided, the last two characters represent the opacity level (from `00` for
763
+ * 0.00 to `99` for 0.99).
764
+ */
765
+ color: string;
766
+ type: 'solidColor';
767
+ /**
768
+ * Control width and height of the solid color overlay. Supported transformations
769
+ * depend on the base/parent asset. See overlays on
770
+ * [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay)
771
+ * and
772
+ * [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay).
773
+ */
774
+ transformation?: Array<SolidColorOverlayTransformation>;
775
+ }
776
+ export interface SolidColorOverlayTransformation {
777
+ /**
778
+ * Specifies the transparency level of the overlaid solid color layer. Supports
779
+ * integers from `1` to `9`.
780
+ */
781
+ alpha?: number;
782
+ /**
783
+ * Specifies the background color of the solid color overlay. Accepts an RGB hex
784
+ * code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name.
785
+ */
786
+ background?: string;
787
+ /**
788
+ * Creates a linear gradient with two colors. Pass `true` for a default gradient,
789
+ * or provide a string for a custom gradient. Only works if the base asset is an
790
+ * image. See
791
+ * [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient).
792
+ */
793
+ gradient?: true | string;
794
+ /**
795
+ * Controls the height of the solid color overlay. Accepts a numeric value or an
796
+ * arithmetic expression. Learn about
797
+ * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations).
798
+ */
799
+ height?: number | string;
800
+ /**
801
+ * Specifies the corner radius of the solid color overlay.
802
+ *
803
+ * - Single value (positive integer): Applied to all corners (e.g., `20`).
804
+ * - `max`: Creates a circular or oval shape.
805
+ * - Per-corner array: Provide four underscore-separated values representing
806
+ * top-left, top-right, bottom-right, and bottom-left corners respectively (e.g.,
807
+ * `10_20_30_40`). See
808
+ * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r).
809
+ */
810
+ radius?: number | 'max' | string;
811
+ /**
812
+ * Controls the width of the solid color overlay. Accepts a numeric value or an
813
+ * arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about
814
+ * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations).
815
+ */
816
+ width?: number | string;
817
+ }
818
+ /**
819
+ * Options for generating ImageKit URLs with transformations. See the
820
+ * [Transformations guide](https://imagekit.io/docs/transformations).
821
+ */
822
+ export interface SrcOptions {
823
+ /**
824
+ * Accepts a relative or absolute path of the resource. If a relative path is
825
+ * provided, it is appended to the `urlEndpoint`. If an absolute path is provided,
826
+ * `urlEndpoint` is ignored.
827
+ */
828
+ src: string;
829
+ /**
830
+ * Get your urlEndpoint from the
831
+ * [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints).
832
+ */
833
+ urlEndpoint: string;
834
+ /**
835
+ * These are additional query parameters that you want to add to the final URL.
836
+ * They can be any query parameters and not necessarily related to ImageKit. This
837
+ * is especially useful if you want to add a versioning parameter to your URLs.
838
+ */
839
+ queryParameters?: {
840
+ [key: string]: string | number;
841
+ };
842
+ /**
843
+ * An array of objects specifying the transformations to be applied in the URL. If
844
+ * more than one transformation is specified, they are applied in the order they
845
+ * are specified as chained transformations. See
846
+ * [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations).
847
+ */
848
+ transformation?: Array<Transformation>;
849
+ /**
850
+ * By default, the transformation string is added as a query parameter in the URL,
851
+ * e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the
852
+ * path of the URL, set this to `path`. Learn more in the
853
+ * [Transformations guide](https://imagekit.io/docs/transformations).
854
+ */
855
+ transformationPosition?: TransformationPosition;
856
+ }
857
+ /**
858
+ * Available streaming resolutions for
859
+ * [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming)
860
+ */
861
+ export type StreamingResolution = '240' | '360' | '480' | '720' | '1080' | '1440' | '2160';
862
+ export interface SubtitleOverlay extends BaseOverlay {
863
+ /**
864
+ * Specifies the relative path to the subtitle file used as an overlay.
865
+ */
866
+ input: string;
867
+ type: 'subtitle';
868
+ /**
869
+ * The input path can be included in the layer as either `i-{input}` or
870
+ * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate
871
+ * format automatically. To always use base64 encoding (`ie-{base64}`), set this
872
+ * parameter to `base64`. To always use plain text (`i-{input}`), set it to
873
+ * `plain`.
874
+ *
875
+ * Regardless of the encoding method:
876
+ *
877
+ * - Leading and trailing slashes are removed.
878
+ * - Remaining slashes within the path are replaced with `@@` when using plain
879
+ * text.
880
+ */
881
+ encoding?: 'auto' | 'plain' | 'base64';
882
+ /**
883
+ * Control styling of the subtitle. See
884
+ * [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer).
885
+ */
886
+ transformation?: Array<SubtitleOverlayTransformation>;
887
+ }
888
+ /**
889
+ * Subtitle styling options.
890
+ * [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
891
+ * from the docs.
892
+ */
893
+ export interface SubtitleOverlayTransformation {
894
+ /**
895
+ * Specifies the subtitle background color using a standard color name, an RGB
896
+ * color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50).
897
+ *
898
+ * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
899
+ */
900
+ background?: string;
901
+ /**
902
+ * Sets the font color of the subtitle text using a standard color name, an RGB
903
+ * color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50).
904
+ *
905
+ * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
906
+ */
907
+ color?: string;
908
+ /**
909
+ * Sets the font family of subtitle text. Refer to the
910
+ * [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list)
911
+ * in the ImageKit transformations guide.
912
+ */
913
+ fontFamily?: string;
914
+ /**
915
+ * Sets the font outline of the subtitle text. Requires the outline width (an
916
+ * integer) and the outline color (as an RGB color code, RGBA color code, or
917
+ * standard web color name) separated by an underscore. Example: `fol-2_blue`
918
+ * (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width of
919
+ * 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of 2px and
920
+ * outline color `#A1CCDD` at 50% opacity).
921
+ *
922
+ * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
923
+ */
924
+ fontOutline?: string;
925
+ /**
926
+ * Sets the font shadow for the subtitle text. Requires the shadow color (as an RGB
927
+ * color code, RGBA color code, or standard web color name) and shadow indent (an
928
+ * integer) separated by an underscore. Example: `fsh-blue_2` (shadow color blue,
929
+ * indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px),
930
+ * `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px).
931
+ *
932
+ * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
933
+ */
934
+ fontShadow?: string;
935
+ /**
936
+ * Sets the font size of subtitle text.
937
+ *
938
+ * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
939
+ */
940
+ fontSize?: number;
941
+ /**
942
+ * Sets the typography style of the subtitle text. Supports values are `b` for
943
+ * bold, `i` for italics, and `b_i` for bold with italics.
944
+ *
945
+ * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer)
946
+ */
947
+ typography?: 'b' | 'i' | 'b_i';
948
+ }
949
+ export interface TextOverlay extends BaseOverlay {
950
+ /**
951
+ * Specifies the text to be displayed in the overlay. The SDK automatically handles
952
+ * special characters and encoding.
953
+ */
954
+ text: string;
955
+ type: 'text';
956
+ /**
957
+ * Text can be included in the layer as either `i-{input}` (plain text) or
958
+ * `ie-{base64_encoded_input}` (base64). By default, the SDK selects the
959
+ * appropriate format based on the input text. To always use base64
960
+ * (`ie-{base64}`), set this parameter to `base64`. To always use plain text
961
+ * (`i-{input}`), set it to `plain`.
962
+ *
963
+ * Regardless of the encoding method, the input text is always percent-encoded to
964
+ * ensure it is URL-safe.
965
+ */
966
+ encoding?: 'auto' | 'plain' | 'base64';
967
+ /**
968
+ * Control styling of the text overlay. See
969
+ * [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay).
970
+ */
971
+ transformation?: Array<TextOverlayTransformation>;
972
+ }
973
+ export interface TextOverlayTransformation {
974
+ /**
975
+ * Specifies the transparency level of the text overlay. Accepts integers from `1`
976
+ * to `9`.
977
+ */
978
+ alpha?: number;
979
+ /**
980
+ * Specifies the background color of the text overlay. Accepts an RGB hex code, an
981
+ * RGBA code, or a color name.
982
+ */
983
+ background?: string;
984
+ /**
985
+ * Flip/mirror the text horizontally, vertically, or in both directions. Acceptable
986
+ * values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or
987
+ * `v_h`.
988
+ */
989
+ flip?: 'h' | 'v' | 'h_v' | 'v_h';
990
+ /**
991
+ * Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g.,
992
+ * `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name.
993
+ */
994
+ fontColor?: string;
995
+ /**
996
+ * Specifies the font family of the overlaid text. Choose from the supported fonts
997
+ * list or use a custom font. See
998
+ * [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list)
999
+ * and
1000
+ * [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay).
1001
+ */
1002
+ fontFamily?: string;
1003
+ /**
1004
+ * Specifies the font size of the overlaid text. Accepts a numeric value or an
1005
+ * arithmetic expression.
1006
+ */
1007
+ fontSize?: number | string;
1008
+ /**
1009
+ * Specifies the inner alignment of the text when width is more than the text
1010
+ * length.
1011
+ */
1012
+ innerAlignment?: 'left' | 'right' | 'center';
1013
+ /**
1014
+ * Specifies the line height for multi-line text overlays. It will come into effect
1015
+ * only if the text wraps over multiple lines. Accepts either an integer value or
1016
+ * an arithmetic expression.
1017
+ */
1018
+ lineHeight?: number | string;
1019
+ /**
1020
+ * Specifies the padding around the overlaid text. Can be provided as a single
1021
+ * positive integer or multiple values separated by underscores (following CSS
1022
+ * shorthand order). Arithmetic expressions are also accepted.
1023
+ */
1024
+ padding?: number | string;
1025
+ /**
1026
+ * Specifies the corner radius:
1027
+ *
1028
+ * - Single value (positive integer): Applied to all corners (e.g., `20`).
1029
+ * - `max`: Creates a circular or oval shape.
1030
+ * - Per-corner array: Provide four underscore-separated values representing
1031
+ * top-left, top-right, bottom-right, and bottom-left corners respectively (e.g.,
1032
+ * `10_20_30_40`). See
1033
+ * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r).
1034
+ */
1035
+ radius?: number | 'max' | string;
1036
+ /**
1037
+ * Specifies the rotation angle of the text overlay. Accepts a numeric value for
1038
+ * clockwise rotation or a string prefixed with "N" for counter-clockwise rotation.
1039
+ */
1040
+ rotation?: number | string;
1041
+ /**
1042
+ * Specifies the typography style of the text. Supported values:
1043
+ *
1044
+ * - Single styles: `b` (bold), `i` (italic), `strikethrough`.
1045
+ * - Combinations: Any combination separated by underscores, e.g., `b_i`,
1046
+ * `b_i_strikethrough`.
1047
+ */
1048
+ typography?: string;
1049
+ /**
1050
+ * Specifies the maximum width (in pixels) of the overlaid text. The text wraps
1051
+ * automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are
1052
+ * supported. Useful when used in conjunction with the `background`. Learn about
1053
+ * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations).
1054
+ */
1055
+ width?: number | string;
1056
+ }
1057
+ /**
1058
+ * The SDK provides easy-to-use names for transformations. These names are
1059
+ * converted to the corresponding transformation string before being added to the
1060
+ * URL. SDKs are updated regularly to support new transformations. If you want to
1061
+ * use a transformation that is not supported by the SDK, You can use the `raw`
1062
+ * parameter to pass the transformation string directly. See the
1063
+ * [Transformations documentation](https://imagekit.io/docs/transformations).
1064
+ */
1065
+ export interface Transformation {
1066
+ /**
1067
+ * Uses AI to change the background. Provide a text prompt or a base64-encoded
1068
+ * prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`.
1069
+ * Not supported inside overlay. See
1070
+ * [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg).
1071
+ */
1072
+ aiChangeBackground?: string;
1073
+ /**
1074
+ * Adds an AI-based drop shadow around a foreground object on a transparent or
1075
+ * removed background. Optionally, control the direction, elevation, and saturation
1076
+ * of the light source (e.g., `az-45` to change light direction). Pass `true` for
1077
+ * the default drop shadow, or provide a string for a custom drop shadow. Supported
1078
+ * inside overlay. See
1079
+ * [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow).
1080
+ */
1081
+ aiDropShadow?: true | string;
1082
+ /**
1083
+ * Uses AI to edit images based on a text prompt. Provide a text prompt or a
1084
+ * base64-encoded prompt, e.g., `prompt-snow road` or
1085
+ * `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay.
1086
+ * See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit).
1087
+ */
1088
+ aiEdit?: string;
1089
+ /**
1090
+ * Applies ImageKit's in-house background removal. Supported inside overlay. See
1091
+ * [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove).
1092
+ */
1093
+ aiRemoveBackground?: true;
1094
+ /**
1095
+ * Uses third-party background removal. Note: It is recommended to use
1096
+ * aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective.
1097
+ * Supported inside overlay. See
1098
+ * [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg).
1099
+ */
1100
+ aiRemoveBackgroundExternal?: true;
1101
+ /**
1102
+ * Performs AI-based retouching to improve faces or product shots. Not supported
1103
+ * inside overlay. See
1104
+ * [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch).
1105
+ */
1106
+ aiRetouch?: true;
1107
+ /**
1108
+ * Upscales images beyond their original dimensions using AI. Not supported inside
1109
+ * overlay. See
1110
+ * [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale).
1111
+ */
1112
+ aiUpscale?: true;
1113
+ /**
1114
+ * Generates a variation of an image using AI. This produces a new image with
1115
+ * slight variations from the original, such as changes in color, texture, and
1116
+ * other visual elements, while preserving the structure and essence of the
1117
+ * original image. Not supported inside overlay. See
1118
+ * [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar).
1119
+ */
1120
+ aiVariation?: true;
1121
+ /**
1122
+ * Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with
1123
+ * either width or height (but not both). For example: aspectRatio = `4:3`, `4_3`,
1124
+ * or an expression like `iar_div_2`. See
1125
+ * [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar).
1126
+ */
1127
+ aspectRatio?: number | string;
1128
+ /**
1129
+ * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See
1130
+ * [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac).
1131
+ */
1132
+ audioCodec?: 'aac' | 'opus' | 'none';
1133
+ /**
1134
+ * Specifies the background to be used in conjunction with certain cropping
1135
+ * strategies when resizing an image.
1136
+ *
1137
+ * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See
1138
+ * [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background).
1139
+ * - Dominant color: `dominant` extracts the dominant color from the image. See
1140
+ * [Dominant color background](https://imagekit.io/docs/effects-and-enhancements#dominant-color-background).
1141
+ * - Gradient: `gradient_dominant` or `gradient_dominant_2` creates a gradient
1142
+ * using the dominant colors. Optionally specify palette size (2 or 4), e.g.,
1143
+ * `gradient_dominant_4`. See
1144
+ * [Gradient background](https://imagekit.io/docs/effects-and-enhancements#gradient-background).
1145
+ * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See
1146
+ * [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background).
1147
+ * - Expand the image boundaries using generative fill: `genfill`. Not supported
1148
+ * inside overlay. Optionally, control the background scene by passing a text
1149
+ * prompt: `genfill[:-prompt-${text}]` or
1150
+ * `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See
1151
+ * [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill).
1152
+ */
1153
+ background?: string;
1154
+ /**
1155
+ * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100,
1156
+ * or an expression like `bl-10`. See
1157
+ * [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl).
1158
+ */
1159
+ blur?: number;
1160
+ /**
1161
+ * Adds a border to the output media. Accepts a string in the format
1162
+ * `<border-width>_<hex-code>` (e.g., `5_FFF000` for a 5px yellow border), or an
1163
+ * expression like `ih_div_20_FF00FF`. See
1164
+ * [Border](https://imagekit.io/docs/effects-and-enhancements#border---b).
1165
+ */
1166
+ border?: string;
1167
+ /**
1168
+ * Indicates whether the output image should retain the original color profile. See
1169
+ * [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp).
1170
+ */
1171
+ colorProfile?: boolean;
1172
+ /**
1173
+ * Replaces colors in the image. Supports three formats:
1174
+ *
1175
+ * - `toColor` - Replace dominant color with the specified color.
1176
+ * - `toColor_tolerance` - Replace dominant color with specified tolerance (0-100).
1177
+ * - `toColor_tolerance_fromColor` - Replace a specific color with another within
1178
+ * tolerance range. Colors can be hex codes (e.g., `FF0022`) or names (e.g.,
1179
+ * `red`, `blue`). See
1180
+ * [Color replacement](https://imagekit.io/docs/effects-and-enhancements#color-replace---cr).
1181
+ */
1182
+ colorReplace?: string;
1183
+ /**
1184
+ * Automatically enhances the contrast of an image (contrast stretch). See
1185
+ * [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast).
1186
+ */
1187
+ contrastStretch?: true;
1188
+ /**
1189
+ * Crop modes for image resizing. See
1190
+ * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus).
1191
+ */
1192
+ crop?: 'force' | 'at_max' | 'at_max_enlarge' | 'at_least' | 'maintain_ratio';
1193
+ /**
1194
+ * Additional crop modes for image resizing. See
1195
+ * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus).
1196
+ */
1197
+ cropMode?: 'pad_resize' | 'extract' | 'pad_extract';
1198
+ /**
1199
+ * Specifies a fallback image if the resource is not found, e.g., a URL or file
1200
+ * path. See
1201
+ * [Default image](https://imagekit.io/docs/image-transformation#default-image---di).
1202
+ */
1203
+ defaultImage?: string;
1204
+ /**
1205
+ * Distorts the shape of an image. Supports two modes:
1206
+ *
1207
+ * - Perspective distortion: `p-x1_y1_x2_y2_x3_y3_x4_y4` changes the position of
1208
+ * the four corners starting clockwise from top-left.
1209
+ * - Arc distortion: `a-degrees` curves the image upwards (positive values) or
1210
+ * downwards (negative values). See
1211
+ * [Distort effect](https://imagekit.io/docs/effects-and-enhancements#distort---e-distort).
1212
+ */
1213
+ distort?: string;
1214
+ /**
1215
+ * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio
1216
+ * (DPR) calculation. Also accepts arithmetic expressions.
1217
+ *
1218
+ * - Learn about
1219
+ * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations).
1220
+ * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr).
1221
+ */
1222
+ dpr?: number;
1223
+ /**
1224
+ * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`.
1225
+ * Typically used with startOffset to indicate the length from the start offset.
1226
+ * Arithmetic expressions are supported. See
1227
+ * [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du).
1228
+ */
1229
+ duration?: number | string;
1230
+ /**
1231
+ * Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`.
1232
+ * Typically used with startOffset to define a time window. Arithmetic expressions
1233
+ * are supported. See
1234
+ * [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo).
1235
+ */
1236
+ endOffset?: number | string;
1237
+ /**
1238
+ * Flips or mirrors an image either horizontally, vertically, or both. Acceptable
1239
+ * values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or
1240
+ * `v_h`. See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl).
1241
+ */
1242
+ flip?: 'h' | 'v' | 'h_v' | 'v_h';
1243
+ /**
1244
+ * Refines padding and cropping behavior for pad resize, maintain ratio, and
1245
+ * extract crop modes. Supports manual positions and coordinate-based focus. With
1246
+ * AI-based cropping, you can automatically keep key subjects in frame—such as
1247
+ * faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— while
1248
+ * resizing.
1249
+ *
1250
+ * - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo).
1251
+ * - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name)
1252
+ */
1253
+ focus?: string;
1254
+ /**
1255
+ * Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`,
1256
+ * `mp4`, or `auto`. You can also pass `orig` for images to return the original
1257
+ * format. ImageKit automatically delivers images and videos in the optimal format
1258
+ * based on device support unless overridden by the dashboard settings or the
1259
+ * format parameter. See
1260
+ * [Image format](https://imagekit.io/docs/image-optimization#format---f) and
1261
+ * [Video format](https://imagekit.io/docs/video-optimization#format---f).
1262
+ */
1263
+ format?: 'auto' | 'webp' | 'jpg' | 'jpeg' | 'png' | 'gif' | 'svg' | 'mp4' | 'webm' | 'avif' | 'orig';
1264
+ /**
1265
+ * Creates a linear gradient with two colors. Pass `true` for a default gradient,
1266
+ * or provide a string for a custom gradient. See
1267
+ * [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient).
1268
+ */
1269
+ gradient?: true | string;
1270
+ /**
1271
+ * Enables a grayscale effect for images. See
1272
+ * [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale).
1273
+ */
1274
+ grayscale?: true;
1275
+ /**
1276
+ * Specifies the height of the output. If a value between 0 and 1 is provided, it
1277
+ * is treated as a percentage (e.g., `0.5` represents 50% of the original height).
1278
+ * You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). Height
1279
+ * transformation –
1280
+ * [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) ·
1281
+ * [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h)
1282
+ */
1283
+ height?: number | string;
1284
+ /**
1285
+ * Specifies whether the output image (in JPEG or PNG) should be compressed
1286
+ * losslessly. See
1287
+ * [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo).
1288
+ */
1289
+ lossless?: boolean;
1290
+ /**
1291
+ * By default, ImageKit removes all metadata during automatic image compression.
1292
+ * Set this to true to preserve metadata. See
1293
+ * [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md).
1294
+ */
1295
+ metadata?: boolean;
1296
+ /**
1297
+ * Named transformation reference. See
1298
+ * [Named transformations](https://imagekit.io/docs/transformations#named-transformations).
1299
+ */
1300
+ named?: string;
1301
+ /**
1302
+ * Specifies the opacity level of the output image. See
1303
+ * [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o).
1304
+ */
1305
+ opacity?: number;
1306
+ /**
1307
+ * If set to true, serves the original file without applying any transformations.
1308
+ * See
1309
+ * [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true).
1310
+ */
1311
+ original?: boolean;
1312
+ /**
1313
+ * Specifies an overlay to be applied on the parent image or video. ImageKit
1314
+ * supports overlays including images, text, videos, subtitles, and solid colors.
1315
+ * See
1316
+ * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers).
1317
+ */
1318
+ overlay?: Overlay;
1319
+ /**
1320
+ * Extracts a specific page or frame from multi-page or layered files (PDF, PSD,
1321
+ * AI). For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the
1322
+ * 2nd and 3rd layers), or by name (e.g., `name-layer-4` for a PSD layer). See
1323
+ * [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files).
1324
+ */
1325
+ page?: number | string;
1326
+ /**
1327
+ * Specifies whether the output JPEG image should be rendered progressively.
1328
+ * Progressive loading begins with a low-quality, pixelated version of the full
1329
+ * image, which gradually improves to provide a faster perceived load time. See
1330
+ * [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr).
1331
+ */
1332
+ progressive?: boolean;
1333
+ /**
1334
+ * Specifies the quality of the output image for lossy formats such as JPEG, WebP,
1335
+ * and AVIF. A higher quality value results in a larger file size with better
1336
+ * quality, while a lower value produces a smaller file size with reduced quality.
1337
+ * See [Quality](https://imagekit.io/docs/image-optimization#quality---q).
1338
+ */
1339
+ quality?: number;
1340
+ /**
1341
+ * Specifies the corner radius for rounded corners.
1342
+ *
1343
+ * - Single value (positive integer): Applied to all corners (e.g., `20`).
1344
+ * - `max`: Creates a circular or oval shape.
1345
+ * - Per-corner array: Provide four underscore-separated values representing
1346
+ * top-left, top-right, bottom-right, and bottom-left corners respectively (e.g.,
1347
+ * `10_20_30_40`). See
1348
+ * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r).
1349
+ */
1350
+ radius?: number | 'max' | string;
1351
+ /**
1352
+ * Pass any transformation not directly supported by the SDK. This transformation
1353
+ * string is appended to the URL as provided.
1354
+ */
1355
+ raw?: string;
1356
+ /**
1357
+ * Specifies the rotation angle in degrees. Positive values rotate the image
1358
+ * clockwise; you can also use, for example, `N40` for counterclockwise rotation or
1359
+ * `auto` to use the orientation specified in the image's EXIF data. For videos,
1360
+ * only the following values are supported: 0, 90, 180, 270, or 360. See
1361
+ * [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt).
1362
+ */
1363
+ rotation?: number | string;
1364
+ /**
1365
+ * Adds a shadow beneath solid objects in an image with a transparent background.
1366
+ * For AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default
1367
+ * shadow, or provide a string for a custom shadow. See
1368
+ * [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow).
1369
+ */
1370
+ shadow?: true | string;
1371
+ /**
1372
+ * Sharpens the input image, highlighting edges and finer details. Pass `true` for
1373
+ * default sharpening, or provide a numeric value for custom sharpening. See
1374
+ * [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen).
1375
+ */
1376
+ sharpen?: true | number;
1377
+ /**
1378
+ * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or
1379
+ * `10.5`. Arithmetic expressions are also supported. See
1380
+ * [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so).
1381
+ */
1382
+ startOffset?: number | string;
1383
+ /**
1384
+ * An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`,
1385
+ * `480`, `720`, `1080`]. See
1386
+ * [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming).
1387
+ */
1388
+ streamingResolutions?: Array<StreamingResolution>;
1389
+ /**
1390
+ * Useful for images with a solid or nearly solid background and a central object.
1391
+ * This parameter trims the background, leaving only the central object in the
1392
+ * output image. See
1393
+ * [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t).
1394
+ */
1395
+ trim?: true | number;
1396
+ /**
1397
+ * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a
1398
+ * default unsharp mask, or provide a string for a custom unsharp mask. See
1399
+ * [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm).
1400
+ */
1401
+ unsharpMask?: true | string;
1402
+ /**
1403
+ * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See
1404
+ * [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc).
1405
+ */
1406
+ videoCodec?: 'h264' | 'vp9' | 'av1' | 'none';
1407
+ /**
1408
+ * Specifies the width of the output. If a value between 0 and 1 is provided, it is
1409
+ * treated as a percentage (e.g., `0.4` represents 40% of the original width). You
1410
+ * can also supply arithmetic expressions (e.g., `iw_div_2`). Width transformation
1411
+ * – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) ·
1412
+ * [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w)
1413
+ */
1414
+ width?: number | string;
1415
+ /**
1416
+ * Focus using cropped image coordinates - X coordinate. See
1417
+ * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates).
1418
+ */
1419
+ x?: number | string;
1420
+ /**
1421
+ * Focus using cropped image coordinates - X center coordinate. See
1422
+ * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates).
1423
+ */
1424
+ xCenter?: number | string;
1425
+ /**
1426
+ * Focus using cropped image coordinates - Y coordinate. See
1427
+ * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates).
1428
+ */
1429
+ y?: number | string;
1430
+ /**
1431
+ * Focus using cropped image coordinates - Y center coordinate. See
1432
+ * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates).
1433
+ */
1434
+ yCenter?: number | string;
1435
+ /**
1436
+ * Accepts a numeric value that determines how much to zoom in or out of the
1437
+ * cropped area. It should be used in conjunction with fo-face or fo-<object_name>.
1438
+ * See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z).
1439
+ */
1440
+ zoom?: number;
1441
+ }
1442
+ /**
1443
+ * By default, the transformation string is added as a query parameter in the URL,
1444
+ * e.g., `?tr=w-100,h-100`. If you want to add the transformation string in the
1445
+ * path of the URL, set this to `path`. Learn more in the
1446
+ * [Transformations guide](https://imagekit.io/docs/transformations).
1447
+ */
1448
+ export type TransformationPosition = 'path' | 'query';
1449
+ export interface VideoOverlay extends BaseOverlay {
1450
+ /**
1451
+ * Specifies the relative path to the video used as an overlay.
1452
+ */
1453
+ input: string;
1454
+ type: 'video';
1455
+ /**
1456
+ * The input path can be included in the layer as either `i-{input}` or
1457
+ * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate
1458
+ * format automatically. To always use base64 encoding (`ie-{base64}`), set this
1459
+ * parameter to `base64`. To always use plain text (`i-{input}`), set it to
1460
+ * `plain`.
1461
+ *
1462
+ * Regardless of the encoding method:
1463
+ *
1464
+ * - Leading and trailing slashes are removed.
1465
+ * - Remaining slashes within the path are replaced with `@@` when using plain
1466
+ * text.
1467
+ */
1468
+ encoding?: 'auto' | 'plain' | 'base64';
1469
+ /**
1470
+ * Array of transformation to be applied to the overlay video. Except
1471
+ * `streamingResolutions`, all other video transformations are supported. See
1472
+ * [Video transformations](https://imagekit.io/docs/video-transformation).
1473
+ */
1474
+ transformation?: Array<Transformation>;
1475
+ }