Skip to content

Commit bc03620

Browse files
committed
Add proper overlay examples
1 parent 397ab31 commit bc03620

File tree

1 file changed

+103
-17
lines changed

1 file changed

+103
-17
lines changed

README.md

Lines changed: 103 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ The SDK’s `.url()` method enables you to generate optimized image and video UR
8888
path: "/default-image.jpg",
8989
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
9090
transformation: [{
91-
"height": "300",
92-
"width": "400"
91+
height: 300,
92+
width: 400
9393
}]
9494
});
9595
```
@@ -103,8 +103,8 @@ The SDK’s `.url()` method enables you to generate optimized image and video UR
103103
var imageURL = imagekit.url({
104104
src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
105105
transformation: [{
106-
"height": "300",
107-
"width": "400"
106+
height: 300,
107+
width: 400
108108
}]
109109
});
110110
```
@@ -121,10 +121,10 @@ Apply multiple transformations by passing an array:
121121
var imageURL = imagekit.url({
122122
path: "/default-image.jpg",
123123
transformation: [{
124-
"height": "300",
125-
"width": "400"
124+
height: 300,
125+
width: 400
126126
}, {
127-
"rotation": 90
127+
rotation: 90
128128
}],
129129
transformationPosition: "query" // Use query parameter for transformations
130130
});
@@ -140,20 +140,106 @@ https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300%2Cw-400%3Art-
140140
var imageURL = imagekit.url({
141141
src: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",
142142
transformation: [{
143-
"width": 400,
144-
"height": 300,
145-
"raw": "l-text,i-Imagekit,fs-50,l-end"
143+
width: 400,
144+
height: 300,
145+
overlay: {
146+
text: "Imagekit",
147+
fontSize: 50,
148+
color: "red",
149+
position: {
150+
x: 10,
151+
y: 20
152+
}
153+
}
146154
}]
147155
});
148156
```
157+
149158
*Image Overlay Example:*
159+
150160
```js
151161
var imageURL = imagekit.url({
152162
src: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",
153163
transformation: [{
154-
"width": 400,
155-
"height": 300,
156-
"raw": "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end"
164+
width: 400,
165+
height: 300,
166+
overlay: {
167+
type: "image",
168+
input: "logo.png",
169+
transformation: [{
170+
width: 100,
171+
border: "10_CDDC39"
172+
}],
173+
position: {
174+
focus: "top_left"
175+
}
176+
}
177+
}]
178+
});
179+
```
180+
181+
*Video Overlay Example:*
182+
183+
```js
184+
var videoOverlayURL = imagekit.url({
185+
src: "https://ik.imagekit.io/your_imagekit_id/base-video.mp4",
186+
transformation: [{
187+
overlay: {
188+
type: "video",
189+
input: "overlay-video.mp4",
190+
position: {
191+
x: "10",
192+
y: "20"
193+
},
194+
timing: {
195+
start: 5,
196+
duration: 10
197+
}
198+
}
199+
}]
200+
});
201+
```
202+
203+
*Subtitle Overlay Example:*
204+
205+
```js
206+
var subtitleOverlayURL = imagekit.url({
207+
src: "https://ik.imagekit.io/your_imagekit_id/base-video.mp4",
208+
transformation: [{
209+
overlay: {
210+
type: "subtitle",
211+
input: "subtitle.vtt",
212+
transformation: [{
213+
fontSize: 16,
214+
fontFamily: "Arial"
215+
}],
216+
position: {
217+
focus: "bottom"
218+
},
219+
timing: {
220+
start: 0,
221+
duration: 5
222+
}
223+
}
224+
}]
225+
});
226+
```
227+
228+
*Solid Color Overlay Example:*
229+
```js
230+
var solidColorOverlayURL = imagekit.url({
231+
src: "https://ik.imagekit.io/your_imagekit_id/base-image.jpg",
232+
transformation: [{
233+
overlay: {
234+
type: "solidColor",
235+
color: "FF0000",
236+
transformation: [{
237+
width: 100,
238+
height: 50,
239+
alpha: 5
240+
}],
241+
position: { x: 20, y: 20 }
242+
}
157243
}]
158244
});
159245
```
@@ -192,9 +278,9 @@ var dropShadowURL = imagekit.url({
192278
var imageURL = imagekit.url({
193279
src: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",
194280
transformation: [{
195-
"width": "iw_div_4",
196-
"height": "ih_div_2",
197-
"border": "cw_mul_0.05_yellow"
281+
width: "iw_div_4",
282+
height: "ih_div_2",
283+
border: "cw_mul_0.05_yellow"
198284
}]
199285
});
200286
```
@@ -269,7 +355,7 @@ For example:
269355
var imageURL = imagekit.url({
270356
path: "/test_path.jpg",
271357
transformation: [{
272-
"newparam": "cool"
358+
newparam: "cool"
273359
}]
274360
});
275361
// Generated URL: https://ik.imagekit.io/test_url_endpoint/tr:newparam-cool/test_path.jpg

0 commit comments

Comments
 (0)