Overlay
A comprehensive guide that covers how you can overlay images and text over another image.

Overlay logo over another image
The above image is created using below URL:
Let's first understand what all is possible in overlay and then you can deep dive into different options available based on what you need. To help you understand, we have added many examples in this documentation.
You can control the position of overlay image relative to base image using overlay focus (ofo), overlay X position (ox) or overlay Y position (oy).
Used to provide granular control over the position of the overlay image relative to the base image.
The top left corner of the input image is considered as (0,0), and the bottom right corner as (w,h), where w is the width and h is the height of the input image. If
ox
is 100, then the overlay image is placed at 100px from the left edge of the input image. If the ox
value exceeds the dimensions of the input image, the values are adjusted and made equal to the corresponding dimension of the input image. Negative values are also supported with a leading N in front of the provided value. Possible Values include any positive integer. If prefixed with
N
, then treated as a negative integer.Used to provide granular control over the position of the overlay image relative to the base image.
The top left corner of the input image is considered as (0,0), and the bottom right corner as (w, h), where w is the width and h is the height of the input image. If
oy
is 150, then the overlay image is placed at 150px from the top edge of the input image. If the oy
value exceeds the dimensions of the input image, the values are adjusted and made equal to the corresponding dimension of the input image. Negative values are also supported with a leading N in front of the provided value.Possible Values include any positive integer. If prefixed with
N
, then treated as a negative integer.Y=30
Y=N30 (Negative value)
X=35 and Y=30
Used to specify the height of the overlay image.
Used to specify the width of the overlaid image.
If you want to overlay a solid color block over a base image, use
obg
parameter.
Possible Values- RGB Hex code: A 6-digit hex code (eg. AAFF00, 0f0fac)
- RGBA Hex code: An 8-digit hex code. Last two characters must be a number between
00
and99
, specifying the opacity level (eg. AAFF0040, 0f0fac75) - Color name: A standard color name in lowercase (eg. lightgreen, beige)
This is supported via alpha component in RGB hex code which takes a numeric value between
00
and 99
, or via oa.obg=00AAFF
obg=00AAFF55 (55% opacity)
You can control the relative position of overlay image using
ofo
parameter. This position is relative to base image.Possible values include
center
, top
, left
, bottom
, right
, top_left
, top_right
, bottom_left
, and bottom_right
.
Default Value - center
Default center
Top
Bottom left
Used to overlay an image on top of another image (base image). This helps you generate watermarked images.
Now to overlay this logo over the base image we will pass the path of overlay image in
oi
parameter i.e. logo-white_SJwqB4Nfe.png
- 1.ImageKit.io currently supports JPEG/JPG and PNG images for overlay.
- 2.The overlay image path should be accessible using your ImageKit.io account.
URL structure
overlay image path base image path
┌──────────────────────â”┌───────────────────────â”
{url-endpoint}/tr:oi-logo-white_SJwqB4Nfe.png/medium_cafe_B1iTdD0C.jpg

In the above example, overlay image logo was stored in home folder i.e.
/
, so there was no slash in the overlay image path. However it could be possible that you have overlay images stored within a specific folder, in that case there will be slashes (/
) in overlay image path. To overcome this you need to replace slash /
with @@
.For example, if the overlay image is at
https://ik.imagekit.io/demo/path/to/overlay.jpg
Then it can be used as an overlay like below:
https://ik.imagekit.io/demo/tr:[email protected]@[email protected]@overlay.jpg/medium_cafe_B1iTdD0C.jpg
By default, ImageKit.io trims the overlay image before overlaying it on the base image. Trimming removes the similar colored pixels from the edges. By default, overlay image is trimmed.
There might be cases where you do not need such trimming to happen. Then, you can do that from the URL itself using the overlay trim (oit) parameter and specifying it as
false
.Possible values include
true
, false
and integer values between 1
and 99
that specify the threshold level for considering a particular pixel as "background".For example, consider the image below, which has the same white logo to be overlaid but this time inside a black rectangular box.
Overlay image logo with black rectangular box - https://ik.imagekit.io/demo/logo_white_black_bg.png​

With trimming (default)
Without trimming
Trim equal to 55
Trim equal to 80
It is used to specify the aspect ratio of the overlay image or the ratio of width to height of the overlay image.
This parameter must be used along with either the overlay height(oh) or overlay width(ow) parameter. The format for specifying this transformation is
oiar-<width>-<height>
.If you specify both overlay height(oh) and overlay width(ow) in the URL along with this parameter, then the overlay image aspect ratio (oiar) is ignored.
oiar=4:3 & 3:4
oiar=4:3 & 9:16
It is used to specify the background color that must be used for the overlay image.
Default Value - Black 00000
Possible Values
- RGB Hex code: A 6-digit hex code (eg. AAFF00, 0f0fac)
- RGBA Hex code: An 8-digit hex code. Last two characters must be a number between
00
and99
, specifying the opacity level (eg. AAFF0040, 0f0fac75) - Color name: A standard color name in lowercase (eg. lightgreen, beige)
This adds a border to the overlay image. It accepts two parameters - the width of the border and the color of the border.
Usage -
oib-<border-width>-<hex code>
The width is specified as a number that is equivalent to the border width in pixels. The color code is specified as a 6-character hex code RRGGBB.
oib=10_FAD6A5 and 10_D73B3E
ob=5_FFFFFF
ob=10_FFFFFF and 10_0F0F0F
It is used to specify the device pixel ratio that is used to calculate the dimensions of the overlay image. Extremely helpful when creating image transformations for devices with high device pixel ratio (DPR > 1), like the iPhone or high-end Android devices.
The
oidpr
parameter can only be used when either the height or width of the desired output overlay image is specified. If the output image's height or width after considering the specified DPR is less than 1px or greater than 5000px, the value of oidpr
is not considered and the overlay height or width used in the URL is used.Possible Values - 0.1 to 5 .
It is used to specify the quality of the overlay image for lossy formats like JPEG and WebP. A large quality number results in a bigger image file size with high overlay image quality. A small quality number results in a smaller image file size with lower overlay image quality.
Default Value - 80 (can be managed from image settings in dashboard)
Cropping in overlay behave the same way as cropping works in ImageKit.io in general. The only difference is that all cropping and focus related parameters are prefixed with
oi
.So essentially:
By default, ImageKit.io trims the overlay image before overlaying it on the base image. Trimming removes the similar colored pixels from the edges. There might be cases where you do not need such trimming to happen. Then, you can do that from the URL using
oit-false
.This removes the transparency of the overlaid image.
Default Value -
true
To overlay text on an image. Supported characters include all alphabets, numbers, spaces, _, -, %, !, @, and &.
Base image
Text overlay example

It is similar to overlay text (ot) but it allows you to overlay special unicode characters (e.g. ©, ®, ™ etc.) that you cannot otherwise pass in a URL as plain string. It accepts base64 string.
- 1.The base64 string should be made URL safe to ensure that all padding characters(=) are included correctly. In Javascript, a function like
encodeURIComponent()
can be used for this. - 2.Input above the length of 144 characters will be truncated.
Here
b3ZlcmxheSBtYWRlIGVhc3k%3D
is the base64 string for "overlay made easy"
To specify the maximum width (in pixels) of the overlaid text on the image. The text is wrapped so that any words in a line that go beyond the given width are sent to the next line. Height of the text box is calculated automatically based on the total number of lines.
Possible values include any integer.
otw=200
otw=400

If you want to give the text block a background color, use this parameter.
Possible Values
- RGB Hex code: A 6-digit hex code (eg. AAFF00, 0f0fac)
- RGBA Hex code: An 8-digit hex code. Last two characters must be a number between
00
and99
, specifying the opacity level (eg. AAFF0040, 0f0fac75) - Color name: A standard color name in lowercase (eg. lightgreen, beige)
This is supported via alpha component in RGB hex code which takes a numeric value between
00
and 99
, or via oa.With solid color background
Solid color background with transparency
To specify the padding around the overlaid text on the image.
Possible values include any positive integer or a set of positive integers separated by underscores.
The set of integers follow CSS shorthand order for determining the padding along each side of the overlay. Learn from the examples:
otp=40
otp=40 and otw=300
otp=25_50_75_100
otp=25_75_60
otp=25_75
- Top padding is 25
- Right padding is 50
- Bottom padding is 75
- Left padding is 100

- Top padding is 25
- Right and left paddings are 75
- Bottom padding is 60

- Top and bottom paddings are 25
- Right and left paddings are 75

To specify the alignment of the overlaid text on the image when text is wrapped with overlay text width (otw).
Possible Values include
left
, right
and center
(default).Left align
Right align
To specify the color and transparency of the overlaid text on the image.
Possible Values
- RGB Hex code: A 6-digit hex code (eg. AAFF00, 0f0fac)
- RGBA Hex code: An 8-digit hex code. Last two characters must be a number between
00
and99
, specifying the opacity level (eg. AAFF0040, 0f0fac75) - Color name: A standard color name in lowercase (eg. lightgreen, beige)
This is supported via alpha component in RGB hex code which takes a numeric value between 00 and 99, or via oa.
otc=00AAFF (no transparancy)
otc=00FFFF55 (55% opacity)
To specify the font of the overlaid text on the image. You can choose any font from this list or use a custom font.
You can use a custom font in text overlay. Upload the font file in your media library and pass the path in
otf
parameter.Text overlay using custom font

Note:
****Here the font-file is available at path
/Lacquer-Regular_nGqtVsBJT.ttf
in media library. You will need to pass the whole path including extension.To specify the size of the overlaid text on the image.
Possible Values include any integer.
To specify the typography of the font used for the overlaid image.
Possible Values include bold
b
and italics i
.To add rounded corners to an overlay background, or to print a circular overlay, use this parameter.
Possible Values include any positive integer.
**Note: **Radius cannot exceed half the length of the shorter side of the overlay element. ‌
or=30 & otbg=FFFFFF80
Circle (or=150 & oh,ow=300)
or=40 & obg=00FFFF80