Skip to content

Commit 557eb49

Browse files
authored
Merge pull request #4 from imagekit-developer/update-overlay-syntax
update overlay syntax
2 parents 2e64325 + c5c093e commit 557eb49

1 file changed

Lines changed: 76 additions & 32 deletions

File tree

README.md

Lines changed: 76 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,82 @@ params := ikurl.UrlParam{
199199
},
200200
}
201201
```
202+
203+
**3. Adding overlays**
204+
205+
ImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations.
206+
207+
**Text as overlays**
208+
209+
You can add any text string over a base video or image using a text layer (l-text).
210+
211+
For example:
212+
213+
```go
214+
params := ikurl.UrlParam{
215+
Path: "default-image.jpg",
216+
UrlEndpoint: "https://ik.imagekit.io/demo-id/",
217+
Transformations: []map[string]any{
218+
{
219+
"height": 300,
220+
"width": 400,
221+
"raw": "l-text,i-Imagekit,fs-50,l-end"
222+
},
223+
},
224+
}
225+
```
226+
**Sample Result URL**
227+
```
228+
https://ik.imagekit.io/demo-id/default-image.jpg?tr=h-300,w-400,l-text,i-Imagekit,fs-50,l-end
229+
```
230+
231+
**Image as overlays**
232+
233+
You can add an image over a base video or image using an image layer (l-image).
234+
235+
For example:
236+
237+
```go
238+
params := ikurl.UrlParam{
239+
Path: "default-image.jpg",
240+
UrlEndpoint: "https://ik.imagekit.io/demo-id/",
241+
Transformations: []map[string]any{
242+
{
243+
"height": 300,
244+
"width": 400,
245+
"raw": "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end"
246+
},
247+
},
248+
}
249+
```
250+
**Sample Result URL**
251+
```
252+
https://ik.imagekit.io/demo-id/default-image.jpg?tr=h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end
253+
```
254+
255+
**Solid color blocks as overlays**
256+
257+
You can add solid color blocks over a base video or image using an image layer (l-image).
258+
259+
For example:
260+
261+
```go
262+
params := ikurl.UrlParam{
263+
Path: "img/sample-video.mp4",
264+
UrlEndpoint: "https://ik.imagekit.io/demo-id/",
265+
Transformations: []map[string]any{
266+
{
267+
"height": 300,
268+
"width": 400,
269+
"raw": "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end"
270+
},
271+
},
272+
}
273+
```
274+
**Sample Result URL**
275+
```
276+
https://ik.imagekit.io/demo-id/img/sample-video.mp4?tr=h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end
277+
```
202278
#### List of supported transformations
203279

204280
See the complete list of transformations supported in ImageKit [here](https://docs.imagekit.io/features/image-transformations). The SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. If the property does not match any of the following supported options, it is added as it is.
@@ -225,38 +301,6 @@ If you want to generate transformations in your application and add them to the
225301
|rotation |rt|
226302
|blur |bl|
227303
|named |n|
228-
|overlayX |ox|
229-
|overlayY |oy|
230-
|overlayFocus |ofo|
231-
|overlayHeight |oh|
232-
|overlayWidth |ow|
233-
|overlayImage |oi|
234-
|overlayImageX |oix|
235-
|overlayImageY |oiy|
236-
|overlayImageXc |oixc|
237-
|overlayImageYc |oiyc|
238-
|overlayImageAspectRatio |oiar|
239-
|overlayImageBackground |oibg|
240-
|overlayImageBorder |oib|
241-
|overlayImageDPR |oidpr|
242-
|overlayImageQuality |oiq|
243-
|overlayImageCropping |oic|
244-
|overlayImageFocus |oifo|
245-
|overlayImageTrim |oit|
246-
|overlayText |ot|
247-
|overlayTextFontSize |ots|
248-
|overlayTextFontFamily |otf|
249-
|overlayTextColor |otc|
250-
|overlayTextTransparency |oa|
251-
|overlayAlpha |oa|
252-
|overlayTextTypography |ott|
253-
|overlayBackground |obg|
254-
|overlayTextEncoded |ote|
255-
|overlayTextWidth |otw|
256-
|overlayTextBackground |otbg|
257-
|overlayTextPadding |otp|
258-
|overlayTextInnerAlignment |otia|
259-
|overlayRadius |or|
260304
|progressive |pr|
261305
|lossless |lo|
262306
|trim |t|

0 commit comments

Comments
 (0)