Skip to content

Commit 6bf6085

Browse files
authored
Merge pull request #62 from imagekit-developer/update-overlay-syntax
updated overlay syntax
2 parents a03aaf0 + f4bb947 commit 6bf6085

File tree

1 file changed

+64
-41
lines changed

1 file changed

+64
-41
lines changed

README.md

Lines changed: 64 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ This section covers the basics:
252252
* [Image enhancement & color manipulation](#2-image-enhancement-and-color-manipulation)
253253
* [Resizing images and videos](#3-resizing-images-and-videos)
254254
* [Quality manipulation](#4-quality-manipulation)
255-
* [Adding overlays to images](#5-adding-overlays-to-images)
255+
* [Adding overlays](#5-adding-overlays)
256256
* [Signed URL](#6-signed-url)
257257

258258
The PHP SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. See the [Full list of supported transformations](#list-of-supported-transformations).
@@ -362,31 +362,83 @@ $imageURL = $imageKit->url(array(
362362
https://ik.imagekit.io/your_imagekit_id/tr:q-40/default-image.jpg
363363
```
364364

365-
### 5. Adding overlays to images
366-
ImageKit.io allows overlaying [images](https://docs.imagekit.io/features/image-transformations/overlay#image-overlay) or [text](https://docs.imagekit.io/features/image-transformations/overlay#text-overlay) over other images and videos for watermarking or creating dynamic assets using custom text.
365+
### 5. Adding overlays
366+
367+
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.
368+
369+
#### Text as overlays
370+
371+
You can add any text string over a base video or image using a text layer (l-text).
372+
373+
For example:
367374

368-
#### Example
369375
```php
370376
$imageURL = $imageKit->url(array(
371377
'path' => '/default-image.jpg',
372378
'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id'
373379

374-
// It means first resize the image to 400x300 and then rotate 90 degree
375380
'transformation' => [
376381
[
377382
'height' => '300',
378-
'width' => '300',
379-
'overlayImage' => 'default-image.jpg',
380-
'overlaywidth' => '100',
381-
'overlayX' => '0',
382-
'overlayImageBorder' => '10_CDDC39' // 10px border of color CDDC39
383+
'width' => '400',
384+
'raw': "l-text,i-Imagekit,fs-50,l-end"
383385
]
384386
]
385387
));
386388
```
387-
#### Response
389+
#### Sample Result URL
390+
```
391+
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-text,i-Imagekit,fs-50,l-end/default-image.jpg
392+
```
393+
394+
#### Image as overlays
395+
396+
You can add an image over a base video or image using an image layer (l-image).
397+
398+
For example:
399+
400+
```php
401+
$imageURL = $imageKit->url(array(
402+
'path' => '/default-image.jpg',
403+
'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id'
404+
405+
'transformation' => [
406+
[
407+
'height' => '300',
408+
'width' => '400',
409+
'raw': "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end"
410+
]
411+
]
412+
));
413+
```
414+
#### Sample Result URL
415+
```
416+
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg
417+
```
418+
419+
#### Solid color blocks as overlays
420+
421+
You can add solid color blocks over a base video or image using an image layer (l-image).
422+
423+
For example:
424+
425+
```php
426+
$imageURL = $imageKit->url(array(
427+
'path' => '/img/sample-video.mp4',
428+
'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id'
429+
430+
'transformation' => [
431+
[
432+
'height' => '300',
433+
'width' => '400',
434+
'raw': "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end"
435+
]
436+
]
437+
));
438+
```
439+
#### Sample Result URL
388440
```
389-
https://ik.imagekit.io/your_imagekit_id/endpoint/tr:w-300,h-300,oi-default-image.jpg,ow-100,ox-0,oib-10_CDDC39/default-image.jpg
441+
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4
390442
```
391443

392444
### 6. Signed URL
@@ -445,35 +497,6 @@ If you want to generate transformations in your application and add them to the
445497
| rotation | rt |
446498
| blur | bl |
447499
| named | n |
448-
| overlayX | ox |
449-
| overlayY | oy |
450-
| overlayFocus | ofo |
451-
| overlayHeight | oh |
452-
| overlayWidth | ow |
453-
| overlayImage | oi |
454-
| overlayImageTrim | oit |
455-
| overlayImageAspectRatio | oiar |
456-
| overlayImageBackground | oibg |
457-
| overlayImageBorder | oib |
458-
| overlayImageDPR | oidpr |
459-
| overlayImageQuality | oiq |
460-
| overlayImageCropping | oic |
461-
| overlayImageFocus | oifo |
462-
| overlayImageTrim | oit |
463-
| overlayText | ot |
464-
| overlayTextFontSize | ots |
465-
| overlayTextFontFamily | otf |
466-
| overlayTextColor | otc |
467-
| overlayTextTransparency | oa |
468-
| overlayAlpha | oa |
469-
| overlayTextTypography | ott |
470-
| overlayBackground | obg |
471-
| overlayTextEncoded | ote |
472-
| overlayTextWidth | otw |
473-
| overlayTextBackground | otbg |
474-
| overlayTextPadding | otp |
475-
| overlayTextInnerAlignment | otia |
476-
| overlayRadius | or |
477500
| progressive | pr |
478501
| lossless | lo |
479502
| trim | t |

0 commit comments

Comments
 (0)