Placing layers on images

Overview

Cloudinary allows you to dynamically add layers to specific locations within your images, where the new layers are added over the base image as overlays, and can also be easily transformed to suit your needs. There are multiple options for adding a new layer to a base image, either an image uploaded to your account, a remote image, or a text string.

An image layer can also be added as an underlay instead, and there are special layer applications for using layers in combination with other Cloudinary transformations.

Here are examples of some popular use cases that you can accomplish using layers (combined with other transformations). Click each image to see the URL parameters applied in each case:

Brand or watermark your images Brand or watermark
your images
Hide all detected faces Hide all
detected faces
Add personalized text Add personalized
text
Displace images on products Displace images
on products

Note
This page describes Cloudinary transformations that apply layers to a specified base image. This differs from delivering images where the original source file has layers that you might reference in a transformation.

Image overlays

Add an image over the base image with the layer parameter (l in URLs) and the public ID of a previously uploaded image (e.g., l_logo for an image with the public ID of logo). For example, adding an overlay of the image called cloudinary_icon_blue to the jpg image named sample.

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon_blue")
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon_blue"))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(Overlay::source(Source::image('cloudinary_icon_blue')));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon_blue")
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon_blue"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_blue"))).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay="cloudinary_icon_blue" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="cloudinary_icon_blue" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="cloudinary_icon_blue">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("cloudinary_icon_blue"))).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("cloudinary_icon_blue")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_blue"))).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.image("cloudinary_icon_blue")))
}.generate()
Image with overlay

Important

  • If the public ID of an image includes a folder component (e.g., the public ID of an image is animals/dog) then replace the slash with a colon when using the image as an overlay (e.g., the public ID of the image becomes animals:dog when used as an overlay).
  • When delivering public images, you can only add other public images as overlays. Even assets set as "authenticated" or "private" using the access_mode parameter can only add public images as overlays. See the Media access control documentation for more details on delivering private and authenticated assets.

Remote image overlays

Use a remote image as an overlay by adding the fetch (or url for some SDKs) property of the layer parameter ( l_fetch: in URLs) and the base64 encoded URL of the remote image. For example, adding an overlay of the remote image https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png to the jpg image named sample.

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :overlay=>{:url=>"https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"})
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("overlay"=>array("url"=>"https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png")))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(Overlay::source(Source::fetch('https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png')));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(overlay={'url': "https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"})
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {overlay: {url: "https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"}})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().overlay(new FetchLayer().url("https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"))).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.FetchLayer().url("https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png")}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {overlay: new cloudinary.FetchLayer().url("https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png")})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay={{url: "https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"}} />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="{url: 'https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png'}" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="fetch:aHR0cHM6Ly9yZXMuY2xvdWRpbmFyeS5jb20vZGVtby9pbWFnZS91cGxvYWQvbG9nb3MvY2xvdWRpbmFyeV9mdWxsX2xvZ29fd2hpdGVfc21hbGwucG5n">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new FetchLayer("https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"))).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("fetch:aHR0cHM6Ly9yZXMuY2xvdWRpbmFyeS5jb20vZGVtby9pbWFnZS91cGxvYWQvbG9nb3MvY2xvdWRpbmFyeV9mdWxsX2xvZ29fd2hpdGVfc21hbGwucG5n")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().overlay(new FetchLayer().url("https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png"))).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.fetch("https://res.cloudinary.com/demo/image/upload/logos/cloudinary_full_logo_white_small.png")))
}.generate()
Image with overlay

Note
The Cloudinary SDKs automatically generate a base64 encoded URL for a given HTTP/S URL, but if you generate the delivery URL in your own code, then you will need to supply the URL in base64 encoding with padding.

Text overlays

Add a text overlay over the base image with the text property of the layer parameter ( l_text: in URLs). The parameter also requires specifying font family and size (separated with an underscore and followed by a colon), and the text string to display. For example, to overlay the text string "Flowers" in the Arial font with a size of 80 pixels (l_text:Arial_80:Flowers):

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :overlay=>{:font_family=>"Arial", :font_size=>80, :text=>"Flowers"})
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("overlay"=>array("font_family"=>"Arial", "font_size"=>80, "text"=>"Flowers")))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(Overlay::source(Source::text('Flowers', (new TextStyle('Arial', 80)))));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(overlay={'font_family': "Arial", 'font_size': 80, 'text': "Flowers"})
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {overlay: {font_family: "Arial", font_size: 80, text: "Flowers"}})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().overlay(new TextLayer().fontFamily("Arial").fontSize(80).text("Flowers"))).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.TextLayer().fontFamily("Arial").fontSize(80).text("Flowers")}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {overlay: new cloudinary.TextLayer().fontFamily("Arial").fontSize(80).text("Flowers")})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay={{fontFamily: "Arial", fontSize: 80, text: "Flowers"}} />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="{fontFamily: 'Arial', fontSize: 80, text: 'Flowers'}" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="text:Arial_80:Flowers">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new TextLayer().FontFamily("Arial").FontSize(80).Text("Flowers"))).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("text:Arial_80:Flowers")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().overlay(new TextLayer().fontFamily("Arial").fontSize(80).text("Flowers"))).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.text("Flowers", TextStyle("Arial", 80))))
}.generate()
Adding dynamic text to image

In addition to the required font and size styling values, you can optionally specify a variety of other CSS-like styling parameters and to further customize your text layers by specifying text color, adding line breaks, emojis and other special characters, and other text layer options.

Layer placement (gravity)

To determine the position of the new layer, you can add the gravity parameter to define a location within the base image ('center' by default). For fine tuning the exact location of the layer, you can offset the overlay from the focus of gravity by also adding the x and y coordinate parameters. These parameters accept either integer values representing the number of pixels to displace the overlay in the horizontal or vertical directions, or real values representing a percentage-based offset relative to the containing image (e.g., 0.2 for an offset of 20%).

Tip
See the Positioning with Gravity interactive demo to experiment with gravity and coordinate parameters.

For example:

  1. Add an overlay of the image called cloudinary_icon_white to the base image with gravity set to west but with a vertical offset of -100 pixels (l_cloudinary_icon_white,g_west,y_-100):

    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon_white", :gravity=>"west", :y=>-100, :width=>0.4, :crop=>"scale")
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon_white", "gravity"=>"west", "y"=>-100, "width"=>"0.4", "crop"=>"scale"))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->overlay(
          Overlay::source(Source::image('cloudinary_icon_white')
            ->transformation((new ImageTransformation())
              ->resize(Resize::scale()->width(0.4))))
          ->position((new Position())
            ->gravity(Gravity::compass(Compass::west()))
            ->offsetY(-100)
      ));
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon_white", gravity="west", y=-100, width="0.4", crop="scale")
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {overlay: "cloudinary_icon_white", gravity: "west", y: -100, width: "0.4", crop: "scale"})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_white")).gravity("west").y(-100).width(0.4).crop("scale")).imageTag("sample.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.Layer().publicId("cloudinary_icon_white"), gravity: "west", y: -100, width: "0.4", crop: "scale"}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {overlay: new cloudinary.Layer().publicId("cloudinary_icon_white"), gravity: "west", y: -100, width: "0.4", crop: "scale"})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation overlay="cloudinary_icon_white" gravity="west" y="-100" width="0.4" crop="scale" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation :overlay="cloudinary_icon_white" gravity="west" y="-100" width="0.4" crop="scale" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation overlay="cloudinary_icon_white" gravity="west" y="-100" width="0.4" crop="scale">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("cloudinary_icon_white")).Gravity("west").Y(-100).Width(0.4).Crop("scale")).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("cloudinary_icon_white").setGravity("west").setY(-100).setWidth(0.4).setCrop("scale")).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_white")).gravity("west").y(-100).width(0.4).crop("scale")).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("sample.jpg")
    overlay(Overlay.source(Source.image("cloudinary_icon_white") {
    transformation(ImageTransformation {
    resize(Resize.scale() {
    width(0.4f)
    })
    })
    }) {
    position(Position {
    gravity(Gravity.compass(Compass.west()))
    offsetY(-100)
    })
    })
    }.generate()
    Image with precisely placed overlay

  2. Add the text string "Welcome" in the Times font with a size of 100 pixels at a vertical distance of 5% from the bottom of the image (l_text:Times_100:Welcome,g_south,y_0.05):

    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :overlay=>{:font_family=>"Times", :font_size=>100, :text=>"Welcome"}, :gravity=>"south", :y=>0.05)
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("overlay"=>array("font_family"=>"Times", "font_size"=>100, "text"=>"Welcome"), "gravity"=>"south", "y"=>"0.05"))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->overlay(Overlay::source(Source::text('Welcome', (new TextStyle('Times', 100))))
        ->position((new Position())
          ->gravity(Gravity::compass(Compass::south()))
          ->offsetY(0.05)));
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(overlay={'font_family': "Times", 'font_size': 100, 'text': "Welcome"}, gravity="south", y="0.05")
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {overlay: {font_family: "Times", font_size: 100, text: "Welcome"}, gravity: "south", y: "0.05"})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation().overlay(new TextLayer().fontFamily("Times").fontSize(100).text("Welcome")).gravity("south").y(0.05)).imageTag("sample.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(100).text("Welcome"), gravity: "south", y: "0.05"}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(100).text("Welcome"), gravity: "south", y: "0.05"})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation overlay={{fontFamily: "Times", fontSize: 100, text: "Welcome"}} gravity="south" y="0.05" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation :overlay="{fontFamily: 'Times', fontSize: 100, text: 'Welcome'}" gravity="south" y="0.05" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation overlay="text:Times_100:Welcome" gravity="south" y="0.05">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new TextLayer().FontFamily("Times").FontSize(100).Text("Welcome")).Gravity("south").Y(0.05)).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("text:Times_100:Welcome").setGravity("south").setY(0.05)).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation().overlay(new TextLayer().fontFamily("Times").fontSize(100).text("Welcome")).gravity("south").y(0.05)).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("sample.jpg")
    overlay(Overlay.source(Source.text("Welcome", TextStyle("Times", 100))) {
    position(Position {
    gravity(Gravity.compass(Compass.south()))
    offsetY(0.05f)
    })
    })
    }.generate()
    Welcome text added to image

Tip
Instead of adding your layer image to a single, specific location, you can tile your layer image over the entire base image. This is often useful when using image layers for watermarking.

Overlays on special positions

The gravity parameter can also be set to a custom region within an image, which becomes the focus when placing the overlay. These 'special positions' are locations within the image that are either automatically detected by Cloudinary (e.g., a face), custom coordinates that were previously specified (e.g., as part of the image upload method), or detected by one of the Cloudinary add-ons (e.g., eyes or text within the image).

For a full list of all the special positions available to use for placing overlays with the gravity parameter, see the <special position> section in the transformation reference guide.

For example:

  1. Add an overlay of the golden_star image over all faces detected in the couple image:

    Ruby:
    Copy to clipboard
    cl_image_tag("couple.jpg", :overlay=>"golden_star", :gravity=>"faces", :width=>50, :crop=>"scale")
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("couple.jpg", array("overlay"=>"golden_star", "gravity"=>"faces", "width"=>50, "crop"=>"scale"))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('couple.jpg'))
      ->overlay(
          Overlay::source(Source::image('golden_star')
            ->transformation((new ImageTransformation())
              ->resize(Resize::scale()->width(50))))
          ->position((new Position())
            ->gravity(Gravity::focusOn(FocusOn::faces()))
      ));
    Python:
    Copy to clipboard
    CloudinaryImage("couple.jpg").image(overlay="golden_star", gravity="faces", width=50, crop="scale")
    Node.js:
    Copy to clipboard
    cloudinary.image("couple.jpg", {overlay: "golden_star", gravity: "faces", width: 50, crop: "scale"})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("golden_star")).gravity("faces").width(50).crop("scale")).imageTag("couple.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('couple.jpg', {overlay: new cloudinary.Layer().publicId("golden_star"), gravity: "faces", width: 50, crop: "scale"}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("couple.jpg", {overlay: new cloudinary.Layer().publicId("golden_star"), gravity: "faces", width: 50, crop: "scale"})
    React:
    Copy to clipboard
    <Image publicId="couple.jpg" >
      <Transformation overlay="golden_star" gravity="faces" width="50" crop="scale" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="couple.jpg" >
      <cld-transformation :overlay="golden_star" gravity="faces" width="50" crop="scale" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="couple.jpg" >
      <cl-transformation overlay="golden_star" gravity="faces" width="50" crop="scale">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("golden_star")).Gravity("faces").Width(50).Crop("scale")).BuildImageTag("couple.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("golden_star").setGravity("faces").setWidth(50).setCrop("scale")).generate("couple.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("golden_star")).gravity("faces").width(50).crop("scale")).generate("couple.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("couple.jpg")
    overlay(Overlay.source(Source.image("golden_star") {
    transformation(ImageTransformation {
    resize(Resize.scale() {
    width(50)
    })
    })
    }) {
    position(Position {
    gravity(Gravity.focusOn(FocusOn.faces()))
    })
    })
    }.generate()
    Image with overlay placed over faces

  2. Use the OCR Text Detection and Extraction add-on to add an overlay with your site's contact information that covers any detected text in an uploaded image:

    Ruby:
    Copy to clipboard
    cl_image_tag("sale_sign.jpg", :overlay=>"call_text", :flags=>"region_relative", :width=>1.1, :gravity=>"ocr_text", :crop=>"scale")
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sale_sign.jpg", array("overlay"=>"call_text", "flags"=>"region_relative", "width"=>"1.1", "gravity"=>"ocr_text", "crop"=>"scale"))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sale_sign.jpg'))
      ->overlay(
          Overlay::source(Source::image('call_text')
            ->transformation((new ImageTransformation())
              ->resize(Resize::scale()->width(1.1)->regionRelative())))
          ->position((new Position())
            ->gravity(Gravity::focusOn(FocusOn::ocr()))
      ));
    Python:
    Copy to clipboard
    CloudinaryImage("sale_sign.jpg").image(overlay="call_text", flags="region_relative", width="1.1", gravity="ocr_text", crop="scale")
    Node.js:
    Copy to clipboard
    cloudinary.image("sale_sign.jpg", {overlay: "call_text", flags: "region_relative", width: "1.1", gravity: "ocr_text", crop: "scale"})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("call_text")).flags("region_relative").width(1.1).gravity("ocr_text").crop("scale")).imageTag("sale_sign.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('sale_sign.jpg', {overlay: new cloudinary.Layer().publicId("call_text"), flags: "region_relative", width: "1.1", gravity: "ocr_text", crop: "scale"}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sale_sign.jpg", {overlay: new cloudinary.Layer().publicId("call_text"), flags: "region_relative", width: "1.1", gravity: "ocr_text", crop: "scale"})
    React:
    Copy to clipboard
    <Image publicId="sale_sign.jpg" >
      <Transformation overlay="call_text" flags="region_relative" width="1.1" gravity="ocr_text" crop="scale" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sale_sign.jpg" >
      <cld-transformation :overlay="call_text" flags="region_relative" width="1.1" gravity="ocr_text" crop="scale" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sale_sign.jpg" >
      <cl-transformation overlay="call_text" flags="region_relative" width="1.1" gravity="ocr_text" crop="scale">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("call_text")).Flags("region_relative").Width(1.1).Gravity("ocr_text").Crop("scale")).BuildImageTag("sale_sign.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("call_text").setFlags("region_relative").setWidth(1.1).setGravity("ocr_text").setCrop("scale")).generate("sale_sign.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("call_text")).flags("region_relative").width(1.1).gravity("ocr_text").crop("scale")).generate("sale_sign.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("sale_sign.jpg")
    overlay(Overlay.source(Source.image("call_text") {
    transformation(ImageTransformation {
    resize(Resize.scale() {
    width(1.1f)
    regionRelative()
    })
    })
    }) {
    position(Position {
    gravity(Gravity.focusOn(FocusOn.ocr()))
    })
    })
    }.generate()
    Image with overlay placed over faces

You may also want to position an overlay ensuring that it avoids a special position. See Position overlays avoiding detected faces for an example of how to achieve this.

Notes

  • When gravity is set to one of the special position values, and no special position is detected in the image, then no overlay is placed at all.
  • Instead of specifying an absolute width for overlays, you can use the fl_region_relative flag to place each overlay relative to the size of each detected region.

Layer placement flags

When placing layers, there are some flags you may want to use to adjust the default behavior.

Relative layer sizing

By default, whenever you apply relative resize transformations to your overlay, the overlay image is resized relative to its own original size. However, you can use one of the following flags to resize relative to other elements.

Sizing relative to the base image

You can add the relative flag (fl_relative in URLs) to specify that percentage-based width & height parameters of overlays (e.g., w_0.5) are relative to the size of the base image instead of to the original size of the overlaying image itself.

The example below adds an overlay of the image called cloudinary_icon_blue, where the overlay is resized to 80% of the width of the base image (l_cloudinary_icon_blue,w_0.8,fl_relative):

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon_blue", :width=>0.8, :flags=>"relative", :crop=>"scale")
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon_blue", "width"=>"0.8", "flags"=>"relative", "crop"=>"scale"))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(
      Overlay::source(Source::image('cloudinary_icon_blue')
        ->transformation((new ImageTransformation())
          ->resize(Resize::scale()->width(0.8)->relative())
  )));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon_blue", width="0.8", flags="relative", crop="scale")
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon_blue", width: "0.8", flags: "relative", crop: "scale"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_blue")).width(0.8).flags("relative").crop("scale")).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue"), width: "0.8", flags: "relative", crop: "scale"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue"), width: "0.8", flags: "relative", crop: "scale"})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay="cloudinary_icon_blue" width="0.8" flags="relative" crop="scale" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="cloudinary_icon_blue" width="0.8" flags="relative" crop="scale" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="cloudinary_icon_blue" width="0.8" flags="relative" crop="scale">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("cloudinary_icon_blue")).Width(0.8).Flags("relative").Crop("scale")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("cloudinary_icon_blue").setWidth(0.8).setFlags("relative").setCrop("scale")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_blue")).width(0.8).flags("relative").crop("scale")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.image("cloudinary_icon_blue") {
transformation(ImageTransformation {
resize(Resize.scale() {
width(0.8f)
relative()
})
})
}))
}.generate()
Image with overlay resized relative to base image

Sizing relative to the detected region

You can add the region_relative flag (fl_region_relative in URLs) to instruct Cloudinary to size your layers relative to the regions detected by the specified gravity type.

  • The region can be detected faces (g_face, g_faces ), detected OCR text regions (g_ocr_text) or pre-defined custom regions (g_custom).
  • This flag must be used in conjunction with a relative (decimal value) width or height qualifier.

The example below hides all the faces in an image by covering them with an emoji overlay, where each overlay is sized at 1.3x (130%) of each detected face:

Ruby:
Copy to clipboard
cl_image_tag("rollercoaster.jpg", :overlay=>"happy_smiley", :width=>1.3, :flags=>"region_relative", :gravity=>"faces", :crop=>"scale")
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("rollercoaster.jpg", array("overlay"=>"happy_smiley", "width"=>"1.3", "flags"=>"region_relative", "gravity"=>"faces", "crop"=>"scale"))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('rollercoaster.jpg'))
  ->overlay(
      Overlay::source(Source::image('happy_smiley')
        ->transformation((new ImageTransformation())
          ->resize(Resize::scale()->width(1.3)->regionRelative())))
      ->position((new Position())
        ->gravity(Gravity::focusOn(FocusOn::faces()))
  ));
Python:
Copy to clipboard
CloudinaryImage("rollercoaster.jpg").image(overlay="happy_smiley", width="1.3", flags="region_relative", gravity="faces", crop="scale")
Node.js:
Copy to clipboard
cloudinary.image("rollercoaster.jpg", {overlay: "happy_smiley", width: "1.3", flags: "region_relative", gravity: "faces", crop: "scale"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("happy_smiley")).width(1.3).flags("region_relative").gravity("faces").crop("scale")).imageTag("rollercoaster.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('rollercoaster.jpg', {overlay: new cloudinary.Layer().publicId("happy_smiley"), width: "1.3", flags: "region_relative", gravity: "faces", crop: "scale"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("rollercoaster.jpg", {overlay: new cloudinary.Layer().publicId("happy_smiley"), width: "1.3", flags: "region_relative", gravity: "faces", crop: "scale"})
React:
Copy to clipboard
<Image publicId="rollercoaster.jpg" >
  <Transformation overlay="happy_smiley" width="1.3" flags="region_relative" gravity="faces" crop="scale" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="rollercoaster.jpg" >
  <cld-transformation :overlay="happy_smiley" width="1.3" flags="region_relative" gravity="faces" crop="scale" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="rollercoaster.jpg" >
  <cl-transformation overlay="happy_smiley" width="1.3" flags="region_relative" gravity="faces" crop="scale">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("happy_smiley")).Width(1.3).Flags("region_relative").Gravity("faces").Crop("scale")).BuildImageTag("rollercoaster.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("happy_smiley").setWidth(1.3).setFlags("region_relative").setGravity("faces").setCrop("scale")).generate("rollercoaster.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("happy_smiley")).width(1.3).flags("region_relative").gravity("faces").crop("scale")).generate("rollercoaster.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("rollercoaster.jpg")
overlay(Overlay.source(Source.image("happy_smiley") {
transformation(ImageTransformation {
resize(Resize.scale() {
width(1.3f)
regionRelative()
})
})
}) {
position(Position {
gravity(Gravity.focusOn(FocusOn.faces()))
})
})
}.generate()
Hide faces in an image with emojis

Layer overflow behavior

By default, if a layer (image or text) has a larger width or height than the base image, the delivered image canvas is resized to display the entire layer. If you want to ensure that the delivered size will never be larger than the base image, you can use the fl_no_overflow flag with your layer.

In the example below, the no_overflow flag prevents the logo overlay from extending the canvas of the base image:

Ruby:
Copy to clipboard
cl_image_tag("flower.jpg", :transformation=>[
  {:width=>400, :crop=>"scale"},
  {:overlay=>"cloudinary_icon_blue", :flags=>"no_overflow"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flower.jpg", array("transformation"=>array(
  array("width"=>400, "crop"=>"scale"),
  array("overlay"=>"cloudinary_icon_blue", "flags"=>"no_overflow")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flower.jpg'))
  ->resize(Resize::scale()->width(400))
  ->overlay(Overlay::source(Source::image('cloudinary_icon_blue'))
    ->position((new Position())
      ->allowOverflow(false)));
Python:
Copy to clipboard
CloudinaryImage("flower.jpg").image(transformation=[
  {'width': 400, 'crop': "scale"},
  {'overlay': "cloudinary_icon_blue", 'flags': "no_overflow"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flower.jpg", {transformation: [
  {width: 400, crop: "scale"},
  {overlay: "cloudinary_icon_blue", flags: "no_overflow"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(400).crop("scale").chain()
  .overlay(new Layer().publicId("cloudinary_icon_blue")).flags("no_overflow")).imageTag("flower.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flower.jpg', {transformation: [
  {width: 400, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue"), flags: "no_overflow"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flower.jpg", {transformation: [
  {width: 400, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue"), flags: "no_overflow"}
  ]})
React:
Copy to clipboard
<Image publicId="flower.jpg" >
  <Transformation width="400" crop="scale" />
  <Transformation overlay="cloudinary_icon_blue" flags="no_overflow" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flower.jpg" >
  <cld-transformation width="400" crop="scale" />
  <cld-transformation :overlay="cloudinary_icon_blue" flags="no_overflow" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flower.jpg" >
  <cl-transformation width="400" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="cloudinary_icon_blue" flags="no_overflow">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(400).Crop("scale").Chain()
  .Overlay(new Layer().PublicId("cloudinary_icon_blue")).Flags("no_overflow")).BuildImageTag("flower.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(400).setCrop("scale").chain()
  .setOverlay("cloudinary_icon_blue").setFlags("no_overflow")).generate("flower.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(400).crop("scale").chain()
  .overlay(new Layer().publicId("cloudinary_icon_blue")).flags("no_overflow")).generate("flower.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flower.jpg")
resize(Resize.scale() {
width(400)
})
overlay(Overlay.source(Source.image("cloudinary_icon_blue")) {
position(Position {
allowOverflow(false)
})
})
}.generate()
Prevent an overlay from extending the canvas of the base image

Layer transformations

Overlays can be resized and transformed like any other image uploaded to Cloudinary. For example, adding an overlay of the image called cloudinary_icon_blue to the top right corner of the base image, where the overlay is also scaled down to 50% of its original width and made into a watermark by reducing the opacity to 70% and increasing the brightness to 50% using the brightness effect (l_cloudinary_icon_blue,w_0.5,c_scale,g_north_east,o_70,e_brightness:50):

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon_blue", :width=>0.5, :gravity=>"north_east", :opacity=>70, :effect=>"brightness:50", :crop=>"scale")
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon_blue", "width"=>"0.5", "gravity"=>"north_east", "opacity"=>70, "effect"=>"brightness:50", "crop"=>"scale"))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(
      Overlay::source(Source::image('cloudinary_icon_blue')
        ->transformation((new ImageTransformation())
          ->resize(Resize::scale()->width(0.5))
          ->adjust(Adjust::opacity(70))
          ->adjust(Adjust::brightness()->level(50))))
      ->position((new Position())
        ->gravity(Gravity::compass(Compass::northEast()))
  ));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon_blue", width="0.5", gravity="north_east", opacity=70, effect="brightness:50", crop="scale")
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon_blue", width: "0.5", gravity: "north_east", opacity: 70, effect: "brightness:50", crop: "scale"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_blue")).width(0.5).gravity("north_east").opacity(70).effect("brightness:50").crop("scale")).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue"), width: "0.5", gravity: "north_east", opacity: 70, effect: "brightness:50", crop: "scale"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue"), width: "0.5", gravity: "north_east", opacity: 70, effect: "brightness:50", crop: "scale"})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay="cloudinary_icon_blue" width="0.5" gravity="north_east" opacity="70" effect="brightness:50" crop="scale" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="cloudinary_icon_blue" width="0.5" gravity="north_east" opacity="70" effect="brightness:50" crop="scale" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="cloudinary_icon_blue" width="0.5" gravity="north_east" opacity="70" effect="brightness:50" crop="scale">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay(new Layer().PublicId("cloudinary_icon_blue")).Width(0.5).Gravity("north_east").Opacity(70).Effect("brightness:50").Crop("scale")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOverlay("cloudinary_icon_blue").setWidth(0.5).setGravity("north_east").setOpacity(70).setEffect("brightness:50").setCrop("scale")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().overlay(new Layer().publicId("cloudinary_icon_blue")).width(0.5).gravity("north_east").opacity(70).effect("brightness:50").crop("scale")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.image("cloudinary_icon_blue") {
transformation(ImageTransformation {
resize(Resize.scale() {
width(0.5f)
})
adjust(Adjust.opacity(70))
adjust(Adjust.brightness() {
level(50)
})
})
}) {
position(Position {
gravity(Gravity.compass(Compass.northEast()))
})
})
}.generate()
Image with transformed overlay

Multiple layer transformations (fl_layer_apply)

You can apply multiple transformations to overlays by adding the layer_apply flag to the 'last' transformation in the series. That is, the flag tells Cloudinary to apply all chained transformations, until a transformation component that includes this flag, on the last added overlay or underlay instead of applying them on the base image (it closes the layer, similar to a closing bracket).

For example, the base image scaled to a width of 500 pixels before adding the woman image as an overlay, where the overlay image is automatically cropped to include only the detected face and then scaled to a width of 150 pixels (w_500/l_woman,c_crop,g_face/w_150/fl_layer_apply):

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>"woman"},
  {:gravity=>"face", :crop=>"crop"},
  {:width=>150, :crop=>"scale"},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>"woman"),
  array("gravity"=>"face", "crop"=>"crop"),
  array("width"=>150, "crop"=>"scale"),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      Overlay::source(Source::image('woman')
        ->transformation((new ImageTransformation())
          ->resize(Resize::crop()->gravity(Gravity::focusOn(FocusOn::face())))
          ->resize(Resize::scale()->width(150))
  )));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': "woman"},
  {'gravity': "face", 'crop': "crop"},
  {'width': 150, 'crop': "scale"},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: "woman"},
  {gravity: "face", crop: "crop"},
  {width: 150, crop: "scale"},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new Layer().publicId("woman")).chain()
  .gravity("face").crop("crop").chain()
  .width(150).crop("scale").chain()
  .flags("layer_apply")).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("woman")},
  {gravity: "face", crop: "crop"},
  {width: 150, crop: "scale"},
  {flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("woman")},
  {gravity: "face", crop: "crop"},
  {width: 150, crop: "scale"},
  {flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay="woman" />
  <Transformation gravity="face" crop="crop" />
  <Transformation width="150" crop="scale" />
  <Transformation flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="woman" />
  <cld-transformation gravity="face" crop="crop" />
  <cld-transformation width="150" crop="scale" />
  <cld-transformation flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="woman">
  </cl-transformation>
  <cl-transformation gravity="face" crop="crop">
  </cl-transformation>
  <cl-transformation width="150" crop="scale">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new Layer().PublicId("woman")).Chain()
  .Gravity("face").Crop("crop").Chain()
  .Width(150).Crop("scale").Chain()
  .Flags("layer_apply")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("woman").chain()
  .setGravity("face").setCrop("crop").chain()
  .setWidth(150).setCrop("scale").chain()
  .setFlags("layer_apply")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new Layer().publicId("woman")).chain()
  .gravity("face").crop("crop").chain()
  .width(150).crop("scale").chain()
  .flags("layer_apply")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.image("woman") {
transformation(ImageTransformation {
resize(Resize.crop() {
gravity(Gravity.focusOn(FocusOn.face()))
})
resize(Resize.scale() {
width(150)
})
})
}))
}.generate()
image with transformations applied to the overlay

Note how the transformations were applied in the last example as chained transformations. The first width adjustment to 500 pixels was made to the base image, and the second width adjustment to 150 pixels was made to the overlay (as was the face detection based cropping) because of the layer_apply flag.

Multiple overlays

Multiple overlays can easily be added as chained transformations to an image. The following example adds both image and text overlays to the base image as follows:

  1. An overlay of an image called couple, cropped to a 120x150 ellipse that includes only the detected faces (l_couple/c_crop,g_faces,w_120,h_150/r_max/fl_layer_apply).
  2. An overlay of an image called cloudinary_icon_white with a relative width of 80% of the base image and an opacity of 50% and a brightness of 100 (l_cloudinary_icon_white,w_0.8,fl_relative/o_50,e_brightness:100/fl_layer_apply).
  3. The text string "Sample image" in Impact bold font with a size of 40 pixels at a distance of 20 pixels from the bottom of the base image (l_text:impact_40_bold:Sample%20image/fl_layer_apply,g_south,y_20).

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :transformation=>[
  {:overlay=>"couple"},
  {:gravity=>"faces", :height=>150, :width=>120, :crop=>"crop"},
  {:radius=>"max"},
  {:flags=>"layer_apply", :gravity=>"north_east"},
  {:overlay=>"cloudinary_icon_white"},
  {:flags=>"relative", :width=>0.8, :crop=>"scale"},
  {:opacity=>50},
  {:effect=>"brightness:100"},
  {:flags=>"layer_apply"},
  {:overlay=>{:font_family=>"impact", :font_size=>40, :font_weight=>"bold", :text=>"Sample%2520image"}},
  {:flags=>"layer_apply", :gravity=>"south", :y=>20}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("overlay"=>"couple"),
  array("gravity"=>"faces", "height"=>150, "width"=>120, "crop"=>"crop"),
  array("radius"=>"max"),
  array("flags"=>"layer_apply", "gravity"=>"north_east"),
  array("overlay"=>"cloudinary_icon_white"),
  array("flags"=>"relative", "width"=>"0.8", "crop"=>"scale"),
  array("opacity"=>50),
  array("effect"=>"brightness:100"),
  array("flags"=>"layer_apply"),
  array("overlay"=>array("font_family"=>"impact", "font_size"=>40, "font_weight"=>"bold", "text"=>"Sample%2520image")),
  array("flags"=>"layer_apply", "gravity"=>"south", "y"=>20)
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(
      Overlay::source(Source::image('couple')
        ->transformation((new ImageTransformation())
          ->resize(Resize::crop()->width(120)->height(150)->gravity(Gravity::focusOn(FocusOn::faces())))
          ->roundCorners(RoundCorners::max())))
      ->position((new Position())
        ->gravity(Gravity::compass(Compass::northEast()))))
    ->overlay(
        Overlay::source(Source::image('cloudinary_icon_white')
          ->transformation((new ImageTransformation())
            ->resize(Resize::scale()->width(0.8)->relative())
            ->adjust(Adjust::opacity(50))
            ->adjust(Adjust::brightness()->level(100)))))
          ->overlay(
              Overlay::source(
                  Source::text('Sample%20image', (new TextStyle('impact', 40))
                    ->fontWeight(FontWeight::bold())))
                ->position((new Position())
                  ->gravity(Gravity::compass(Compass::south()))
                  ->offsetY(20)
              
            
              
              ));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(transformation=[
  {'overlay': "couple"},
  {'gravity': "faces", 'height': 150, 'width': 120, 'crop': "crop"},
  {'radius': "max"},
  {'flags': "layer_apply", 'gravity': "north_east"},
  {'overlay': "cloudinary_icon_white"},
  {'flags': "relative", 'width': "0.8", 'crop': "scale"},
  {'opacity': 50},
  {'effect': "brightness:100"},
  {'flags': "layer_apply"},
  {'overlay': {'font_family': "impact", 'font_size': 40, 'font_weight': "bold", 'text': "Sample%2520image"}},
  {'flags': "layer_apply", 'gravity': "south", 'y': 20}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {transformation: [
  {overlay: "couple"},
  {gravity: "faces", height: 150, width: 120, crop: "crop"},
  {radius: "max"},
  {flags: "layer_apply", gravity: "north_east"},
  {overlay: "cloudinary_icon_white"},
  {flags: "relative", width: "0.8", crop: "scale"},
  {opacity: 50},
  {effect: "brightness:100"},
  {flags: "layer_apply"},
  {overlay: {font_family: "impact", font_size: 40, font_weight: "bold", text: "Sample%2520image"}},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .overlay(new Layer().publicId("couple")).chain()
  .gravity("faces").height(150).width(120).crop("crop").chain()
  .radius("max").chain()
  .flags("layer_apply").gravity("north_east").chain()
  .overlay(new Layer().publicId("cloudinary_icon_white")).chain()
  .flags("relative").width(0.8).crop("scale").chain()
  .opacity(50).chain()
  .effect("brightness:100").chain()
  .flags("layer_apply").chain()
  .overlay(new TextLayer().fontFamily("impact").fontSize(40).fontWeight("bold").text("Sample%2520image")).chain()
  .flags("layer_apply").gravity("south").y(20)).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {transformation: [
  {overlay: new cloudinary.Layer().publicId("couple")},
  {gravity: "faces", height: 150, width: 120, crop: "crop"},
  {radius: "max"},
  {flags: "layer_apply", gravity: "north_east"},
  {overlay: new cloudinary.Layer().publicId("cloudinary_icon_white")},
  {flags: "relative", width: "0.8", crop: "scale"},
  {opacity: 50},
  {effect: "brightness:100"},
  {flags: "layer_apply"},
  {overlay: new cloudinary.TextLayer().fontFamily("impact").fontSize(40).fontWeight("bold").text("Sample%2520image")},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {transformation: [
  {overlay: new cloudinary.Layer().publicId("couple")},
  {gravity: "faces", height: 150, width: 120, crop: "crop"},
  {radius: "max"},
  {flags: "layer_apply", gravity: "north_east"},
  {overlay: new cloudinary.Layer().publicId("cloudinary_icon_white")},
  {flags: "relative", width: "0.8", crop: "scale"},
  {opacity: 50},
  {effect: "brightness:100"},
  {flags: "layer_apply"},
  {overlay: new cloudinary.TextLayer().fontFamily("impact").fontSize(40).fontWeight("bold").text("Sample%2520image")},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay="couple" />
  <Transformation gravity="faces" height="150" width="120" crop="crop" />
  <Transformation radius="max" />
  <Transformation flags="layer_apply" gravity="north_east" />
  <Transformation overlay="cloudinary_icon_white" />
  <Transformation flags="relative" width="0.8" crop="scale" />
  <Transformation opacity="50" />
  <Transformation effect="brightness:100" />
  <Transformation flags="layer_apply" />
  <Transformation overlay={{fontFamily: "impact", fontSize: 40, fontWeight: "bold", text: "Sample%2520image"}} />
  <Transformation flags="layer_apply" gravity="south" y="20" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="couple" />
  <cld-transformation gravity="faces" height="150" width="120" crop="crop" />
  <cld-transformation radius="max" />
  <cld-transformation flags="layer_apply" gravity="north_east" />
  <cld-transformation :overlay="cloudinary_icon_white" />
  <cld-transformation flags="relative" width="0.8" crop="scale" />
  <cld-transformation opacity="50" />
  <cld-transformation effect="brightness:100" />
  <cld-transformation flags="layer_apply" />
  <cld-transformation :overlay="{fontFamily: 'impact', fontSize: 40, fontWeight: 'bold', text: 'Sample%2520image'}" />
  <cld-transformation flags="layer_apply" gravity="south" y="20" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="couple">
  </cl-transformation>
  <cl-transformation gravity="faces" height="150" width="120" crop="crop">
  </cl-transformation>
  <cl-transformation radius="max">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="north_east">
  </cl-transformation>
  <cl-transformation overlay="cloudinary_icon_white">
  </cl-transformation>
  <cl-transformation flags="relative" width="0.8" crop="scale">
  </cl-transformation>
  <cl-transformation opacity="50">
  </cl-transformation>
  <cl-transformation effect="brightness:100">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
  <cl-transformation overlay="text:impact_40_bold:Sample%2520image">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="south" y="20">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new Layer().PublicId("couple")).Chain()
  .Gravity("faces").Height(150).Width(120).Crop("crop").Chain()
  .Radius("max").Chain()
  .Flags("layer_apply").Gravity("north_east").Chain()
  .Overlay(new Layer().PublicId("cloudinary_icon_white")).Chain()
  .Flags("relative").Width(0.8).Crop("scale").Chain()
  .Opacity(50).Chain()
  .Effect("brightness:100").Chain()
  .Flags("layer_apply").Chain()
  .Overlay(new TextLayer().FontFamily("impact").FontSize(40).FontWeight("bold").Text("Sample%2520image")).Chain()
  .Flags("layer_apply").Gravity("south").Y(20)).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setOverlay("couple").chain()
  .setGravity("faces").setHeight(150).setWidth(120).setCrop("crop").chain()
  .setRadius("max").chain()
  .setFlags("layer_apply").setGravity("north_east").chain()
  .setOverlay("cloudinary_icon_white").chain()
  .setFlags("relative").setWidth(0.8).setCrop("scale").chain()
  .setOpacity(50).chain()
  .setEffect("brightness:100").chain()
  .setFlags("layer_apply").chain()
  .setOverlay("text:impact_40_bold:Sample%2520image").chain()
  .setFlags("layer_apply").setGravity("south").setY(20)).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .overlay(new Layer().publicId("couple")).chain()
  .gravity("faces").height(150).width(120).crop("crop").chain()
  .radius("max").chain()
  .flags("layer_apply").gravity("north_east").chain()
  .overlay(new Layer().publicId("cloudinary_icon_white")).chain()
  .flags("relative").width(0.8).crop("scale").chain()
  .opacity(50).chain()
  .effect("brightness:100").chain()
  .flags("layer_apply").chain()
  .overlay(new TextLayer().fontFamily("impact").fontSize(40).fontWeight("bold").text("Sample%2520image")).chain()
  .flags("layer_apply").gravity("south").y(20)).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.image("couple") {
transformation(ImageTransformation {
resize(Resize.crop() {
width(120)
height(150)
gravity(Gravity.focusOn(FocusOn.faces()))
})
roundCorners(RoundCorners.max())
})
}) {
position(Position {
gravity(Gravity.compass(Compass.northEast()))
})
})
overlay(Overlay.source(Source.image("cloudinary_icon_white") {
transformation(ImageTransformation {
resize(Resize.scale() {
width(0.8f)
relative()
})
adjust(Adjust.opacity(50))
adjust(Adjust.brightness() {
level(100)
})
})
}))
overlay(Overlay.source(Source.text("Sample%20image", TextStyle("impact", 40) {
fontWeight(FontWeight.bold())
})) {
position(Position {
gravity(Gravity.compass(Compass.south()))
offsetY(20)
})
})
}.generate()
Image with 3 overlays

Considerations when using layer_apply

  1. When adding multiple layers, close all layers with the layer_apply flag (even if they don't use multiple components) to avoid server confusion on which transformations to apply to a particular layer.
  2. Specify any details regarding the relationship between the overlay image and the base image (i.e., anything that is relative like gravity) in the same component as the layer_apply flag. For example the base image scaled to a width of 500 pixels before adding the cloudinary_icon_blue image as an overlay, where the overlay image is scaled to a width of 150 pixels, converted to black and white, and then the entire overlay is placed in the top right corner:
    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>500, :crop=>"scale"},
      {:overlay=>"cloudinary_icon_blue"},
      {:width=>150, :crop=>"scale"},
      {:effect=>"blackwhite"},
      {:flags=>"layer_apply", :gravity=>"north_east"}
      ])
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>500, "crop"=>"scale"),
      array("overlay"=>"cloudinary_icon_blue"),
      array("width"=>150, "crop"=>"scale"),
      array("effect"=>"blackwhite"),
      array("flags"=>"layer_apply", "gravity"=>"north_east")
      )))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->resize(Resize::scale()->width(500))
      ->overlay(
          Overlay::source(Source::image('cloudinary_icon_blue')
            ->transformation((new ImageTransformation())
              ->resize(Resize::scale()->width(150))
              ->effect(Effect::blackwhite())))
          ->position((new Position())
            ->gravity(Gravity::compass(Compass::northEast()))
      ));
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(transformation=[
      {'width': 500, 'crop': "scale"},
      {'overlay': "cloudinary_icon_blue"},
      {'width': 150, 'crop': "scale"},
      {'effect': "blackwhite"},
      {'flags': "layer_apply", 'gravity': "north_east"}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {transformation: [
      {width: 500, crop: "scale"},
      {overlay: "cloudinary_icon_blue"},
      {width: 150, crop: "scale"},
      {effect: "blackwhite"},
      {flags: "layer_apply", gravity: "north_east"}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .width(500).crop("scale").chain()
      .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
      .width(150).crop("scale").chain()
      .effect("blackwhite").chain()
      .flags("layer_apply").gravity("north_east")).imageTag("sample.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {transformation: [
      {width: 500, crop: "scale"},
      {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
      {width: 150, crop: "scale"},
      {effect: "blackwhite"},
      {flags: "layer_apply", gravity: "north_east"}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 500, crop: "scale"},
      {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
      {width: 150, crop: "scale"},
      {effect: "blackwhite"},
      {flags: "layer_apply", gravity: "north_east"}
      ]})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation width="500" crop="scale" />
      <Transformation overlay="cloudinary_icon_blue" />
      <Transformation width="150" crop="scale" />
      <Transformation effect="blackwhite" />
      <Transformation flags="layer_apply" gravity="north_east" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation width="500" crop="scale" />
      <cld-transformation :overlay="cloudinary_icon_blue" />
      <cld-transformation width="150" crop="scale" />
      <cld-transformation effect="blackwhite" />
      <cld-transformation flags="layer_apply" gravity="north_east" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation width="500" crop="scale">
      </cl-transformation>
      <cl-transformation overlay="cloudinary_icon_blue">
      </cl-transformation>
      <cl-transformation width="150" crop="scale">
      </cl-transformation>
      <cl-transformation effect="blackwhite">
      </cl-transformation>
      <cl-transformation flags="layer_apply" gravity="north_east">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(500).Crop("scale").Chain()
      .Overlay(new Layer().PublicId("cloudinary_icon_blue")).Chain()
      .Width(150).Crop("scale").Chain()
      .Effect("blackwhite").Chain()
      .Flags("layer_apply").Gravity("north_east")).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setWidth(500).setCrop("scale").chain()
      .setOverlay("cloudinary_icon_blue").chain()
      .setWidth(150).setCrop("scale").chain()
      .setEffect("blackwhite").chain()
      .setFlags("layer_apply").setGravity("north_east")).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .width(500).crop("scale").chain()
      .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
      .width(150).crop("scale").chain()
      .effect("blackwhite").chain()
      .flags("layer_apply").gravity("north_east")).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("sample.jpg")
    resize(Resize.scale() {
    width(500)
    })
    overlay(Overlay.source(Source.image("cloudinary_icon_blue") {
    transformation(ImageTransformation {
    resize(Resize.scale() {
    width(150)
    })
    effect(Effect.blackwhite())
    })
    }) {
    position(Position {
    gravity(Gravity.compass(Compass.northEast()))
    })
    })
    }.generate()
    image with gravity applied to the overlay and relative to the base image
  3. Layers can be nested within layers. For example, the same image as above with another cloudinary_icon_blue image added as an overlay to the first (black and white) overlay.
    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>500, :crop=>"scale"},
      {:overlay=>"cloudinary_icon_blue"},
      {:width=>150, :crop=>"scale"},
      {:effect=>"blackwhite"},
      {:overlay=>"cloudinary_icon_blue"},
      {:width=>50, :crop=>"scale"},
      {:flags=>"layer_apply"},
      {:flags=>"layer_apply", :gravity=>"north_east"}
      ])
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>500, "crop"=>"scale"),
      array("overlay"=>"cloudinary_icon_blue"),
      array("width"=>150, "crop"=>"scale"),
      array("effect"=>"blackwhite"),
      array("overlay"=>"cloudinary_icon_blue"),
      array("width"=>50, "crop"=>"scale"),
      array("flags"=>"layer_apply"),
      array("flags"=>"layer_apply", "gravity"=>"north_east")
      )))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->resize(Resize::scale()->width(500))
      ->overlay(
          Overlay::source(Source::image('cloudinary_icon_blue')
            ->transformation((new ImageTransformation())
              ->resize(Resize::scale()->width(150))
              ->effect(Effect::blackwhite())
              ->overlay(
                  Overlay::source(Source::image('cloudinary_icon_blue')
                    ->transformation((new ImageTransformation())
                      ->resize(Resize::scale()->width(50)))))))
            ->position((new Position())
              ->gravity(Gravity::compass(Compass::northEast()))
          
              ));
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(transformation=[
      {'width': 500, 'crop': "scale"},
      {'overlay': "cloudinary_icon_blue"},
      {'width': 150, 'crop': "scale"},
      {'effect': "blackwhite"},
      {'overlay': "cloudinary_icon_blue"},
      {'width': 50, 'crop': "scale"},
      {'flags': "layer_apply"},
      {'flags': "layer_apply", 'gravity': "north_east"}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {transformation: [
      {width: 500, crop: "scale"},
      {overlay: "cloudinary_icon_blue"},
      {width: 150, crop: "scale"},
      {effect: "blackwhite"},
      {overlay: "cloudinary_icon_blue"},
      {width: 50, crop: "scale"},
      {flags: "layer_apply"},
      {flags: "layer_apply", gravity: "north_east"}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .width(500).crop("scale").chain()
      .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
      .width(150).crop("scale").chain()
      .effect("blackwhite").chain()
      .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
      .width(50).crop("scale").chain()
      .flags("layer_apply").chain()
      .flags("layer_apply").gravity("north_east")).imageTag("sample.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {transformation: [
      {width: 500, crop: "scale"},
      {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
      {width: 150, crop: "scale"},
      {effect: "blackwhite"},
      {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
      {width: 50, crop: "scale"},
      {flags: "layer_apply"},
      {flags: "layer_apply", gravity: "north_east"}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 500, crop: "scale"},
      {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
      {width: 150, crop: "scale"},
      {effect: "blackwhite"},
      {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
      {width: 50, crop: "scale"},
      {flags: "layer_apply"},
      {flags: "layer_apply", gravity: "north_east"}
      ]})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation width="500" crop="scale" />
      <Transformation overlay="cloudinary_icon_blue" />
      <Transformation width="150" crop="scale" />
      <Transformation effect="blackwhite" />
      <Transformation overlay="cloudinary_icon_blue" />
      <Transformation width="50" crop="scale" />
      <Transformation flags="layer_apply" />
      <Transformation flags="layer_apply" gravity="north_east" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation width="500" crop="scale" />
      <cld-transformation :overlay="cloudinary_icon_blue" />
      <cld-transformation width="150" crop="scale" />
      <cld-transformation effect="blackwhite" />
      <cld-transformation :overlay="cloudinary_icon_blue" />
      <cld-transformation width="50" crop="scale" />
      <cld-transformation flags="layer_apply" />
      <cld-transformation flags="layer_apply" gravity="north_east" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation width="500" crop="scale">
      </cl-transformation>
      <cl-transformation overlay="cloudinary_icon_blue">
      </cl-transformation>
      <cl-transformation width="150" crop="scale">
      </cl-transformation>
      <cl-transformation effect="blackwhite">
      </cl-transformation>
      <cl-transformation overlay="cloudinary_icon_blue">
      </cl-transformation>
      <cl-transformation width="50" crop="scale">
      </cl-transformation>
      <cl-transformation flags="layer_apply">
      </cl-transformation>
      <cl-transformation flags="layer_apply" gravity="north_east">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(500).Crop("scale").Chain()
      .Overlay(new Layer().PublicId("cloudinary_icon_blue")).Chain()
      .Width(150).Crop("scale").Chain()
      .Effect("blackwhite").Chain()
      .Overlay(new Layer().PublicId("cloudinary_icon_blue")).Chain()
      .Width(50).Crop("scale").Chain()
      .Flags("layer_apply").Chain()
      .Flags("layer_apply").Gravity("north_east")).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setWidth(500).setCrop("scale").chain()
      .setOverlay("cloudinary_icon_blue").chain()
      .setWidth(150).setCrop("scale").chain()
      .setEffect("blackwhite").chain()
      .setOverlay("cloudinary_icon_blue").chain()
      .setWidth(50).setCrop("scale").chain()
      .setFlags("layer_apply").chain()
      .setFlags("layer_apply").setGravity("north_east")).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .width(500).crop("scale").chain()
      .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
      .width(150).crop("scale").chain()
      .effect("blackwhite").chain()
      .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
      .width(50).crop("scale").chain()
      .flags("layer_apply").chain()
      .flags("layer_apply").gravity("north_east")).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("sample.jpg")
    resize(Resize.scale() {
    width(500)
    })
    overlay(Overlay.source(Source.image("cloudinary_icon_blue") {
    transformation(ImageTransformation {
    resize(Resize.scale() {
    width(150)
    })
    effect(Effect.blackwhite())
    overlay(Overlay.source(Source.image("cloudinary_icon_blue") {
    transformation(ImageTransformation {
    resize(Resize.scale() {
    width(50)
    })
    })
    }))
    })
    }) {
    position(Position {
    gravity(Gravity.compass(Compass.northEast()))
    })
    })
    }.generate()
    image with nested layers

Text layer options

Text overlays are actually an image created on the fly and can be further transformed like any other image uploaded to Cloudinary. For example, adding the text string "Welcome", then applying a green outline effect, and resizing the text to be 80% of the width of the base image (l_text:Times_80:Welcome/co_green,e_outline/c_scale,fl_relative,w_0.8/fl_layer_apply):

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :transformation=>[
  {:overlay=>{:font_family=>"Times", :font_size=>80, :text=>"Welcome"}},
  {:color=>"green", :effect=>"outline"},
  {:flags=>"relative", :width=>0.8, :crop=>"scale"},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("overlay"=>array("font_family"=>"Times", "font_size"=>80, "text"=>"Welcome")),
  array("color"=>"green", "effect"=>"outline"),
  array("flags"=>"relative", "width"=>"0.8", "crop"=>"scale"),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(
      Overlay::source(Source::text('Welcome', (new TextStyle('Times', 80)))
        ->transformation((new ImageTransformation())
          ->effect(Effect::outline()->color(Color::GREEN))
          ->resize(Resize::scale()->width(0.8)->relative())
  )));
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(transformation=[
  {'overlay': {'font_family': "Times", 'font_size': 80, 'text': "Welcome"}},
  {'color': "green", 'effect': "outline"},
  {'flags': "relative", 'width': "0.8", 'crop': "scale"},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {transformation: [
  {overlay: {font_family: "Times", font_size: 80, text: "Welcome"}},
  {color: "green", effect: "outline"},
  {flags: "relative", width: "0.8", crop: "scale"},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .overlay(new TextLayer().fontFamily("Times").fontSize(80).text("Welcome")).chain()
  .color("green").effect("outline").chain()
  .flags("relative").width(0.8).crop("scale").chain()
  .flags("layer_apply")).imageTag("sample.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('sample.jpg', {transformation: [
  {overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(80).text("Welcome")},
  {color: "green", effect: "outline"},
  {flags: "relative", width: "0.8", crop: "scale"},
  {flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {transformation: [
  {overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(80).text("Welcome")},
  {color: "green", effect: "outline"},
  {flags: "relative", width: "0.8", crop: "scale"},
  {flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay={{fontFamily: "Times", fontSize: 80, text: "Welcome"}} />
  <Transformation color="green" effect="outline" />
  <Transformation flags="relative" width="0.8" crop="scale" />
  <Transformation flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="{fontFamily: 'Times', fontSize: 80, text: 'Welcome'}" />
  <cld-transformation color="green" effect="outline" />
  <cld-transformation flags="relative" width="0.8" crop="scale" />
  <cld-transformation flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="text:Times_80:Welcome">
  </cl-transformation>
  <cl-transformation color="green" effect="outline">
  </cl-transformation>
  <cl-transformation flags="relative" width="0.8" crop="scale">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new TextLayer().FontFamily("Times").FontSize(80).Text("Welcome")).Chain()
  .Color("green").Effect("outline").Chain()
  .Flags("relative").Width(0.8).Crop("scale").Chain()
  .Flags("layer_apply")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setOverlay("text:Times_80:Welcome").chain()
  .setColor("green").setEffect("outline").chain()
  .setFlags("relative").setWidth(0.8).setCrop("scale").chain()
  .setFlags("layer_apply")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .overlay(new TextLayer().fontFamily("Times").fontSize(80).text("Welcome")).chain()
  .color("green").effect("outline").chain()
  .flags("relative").width(0.8).crop("scale").chain()
  .flags("layer_apply")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("sample.jpg")
overlay(Overlay.source(Source.text("Welcome", TextStyle("Times", 80)) {
transformation(ImageTransformation {
effect(Effect.outline() {
color(Color.GREEN)
})
resize(Resize.scale() {
width(0.8f)
relative()
})
})
}))
}.generate()
Text with transformations

The text layer itself can also be customized in appearance in a variety of ways, as detailed in the remainder of this section.

Styling parameters

In addition to the required font family and font size values, a variety of optional CSS-like styles are supported, such as decoration, alignment, letter spacing and more. For a full list, see the Styling parameters table in the reference guide.

The Cloudinary SDK helper methods support supplying the values as an array of mapped values or as a serialized string of values. For example, in Ruby (other frameworks use similar syntax): overlay: { text: 'Hello World', font_family: 'Arial', font_size: 18, font_weight: 'bold', font_style: 'italic', letter_spacing: 4 }

For example, to overlay the text string "Flowers" in Verdana bold with a size of 75 pixels, underlined, and with 14 pixels spacing between the letters: l_text:verdana_75_bold_underline_letter_spacing_14:Flowers:

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>{:font_family=>"Verdana", :font_size=>75, :font_weight=>"bold", :text_decoration=>"underline", :letter_spacing=>14, :text=>"Flowers"}},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>array("font_family"=>"Verdana", "font_size"=>75, "font_weight"=>"bold", "text_decoration"=>"underline", "letter_spacing"=>14, "text"=>"Flowers")),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      Overlay::source(
          Source::text('Flowers', (new TextStyle('Verdana', 75))
            ->fontWeight(FontWeight::bold())
            ->textDecoration(TextDecoration::underline())
            ->letterSpacing(14)
      
      )));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': {'font_family': "Verdana", 'font_size': 75, 'font_weight': "bold", 'text_decoration': "underline", 'letter_spacing': 14, 'text': "Flowers"}},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: {font_family: "Verdana", font_size: 75, font_weight: "bold", text_decoration: "underline", letter_spacing: 14, text: "Flowers"}},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Verdana").fontSize(75).fontWeight("bold").textDecoration("underline").letterSpacing(14).text("Flowers")).chain()
  .flags("layer_apply")).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Verdana").fontSize(75).fontWeight("bold").textDecoration("underline").letterSpacing(14).text("Flowers")},
  {flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Verdana").fontSize(75).fontWeight("bold").textDecoration("underline").letterSpacing(14).text("Flowers")},
  {flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay={{fontFamily: "Verdana", fontSize: 75, fontWeight: "bold", textDecoration: "underline", letterSpacing: 14, text: "Flowers"}} />
  <Transformation flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="{fontFamily: 'Verdana', fontSize: 75, fontWeight: 'bold', textDecoration: 'underline', letterSpacing: 14, text: 'Flowers'}" />
  <cld-transformation flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="text:Verdana_75_bold_underline_letter_spacing_14:Flowers">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new TextLayer().FontFamily("Verdana").FontSize(75).FontWeight("bold").TextDecoration("underline").LetterSpacing(14).Text("Flowers")).Chain()
  .Flags("layer_apply")).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("text:Verdana_75_bold_underline_letter_spacing_14:Flowers").chain()
  .setFlags("layer_apply")).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Verdana").fontSize(75).fontWeight("bold").textDecoration("underline").letterSpacing(14).text("Flowers")).chain()
  .flags("layer_apply")).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Flowers", TextStyle("Verdana", 75) {
fontWeight(FontWeight.bold())
textDecoration(TextDecoration.underline())
letterSpacing(14)
})))
}.generate()
Adding text to image

Text color

You can control the color of the text overlay by adding the color property (co in URLs).

Opaque colors can be set as an RGB hex triplet (e.g., co_rgb:3e2222), a 3-digit RGB hex (e.g., co_rgb:777) or a named color (e.g., co_green). Cloudinary's client libraries also support a # shortcut for RGB (e.g., setting the color to #3e2222 which is then translated to co_rgb:3e2222). By default, if the color property is omitted then the text has a black color.

For example, adding the text string "Cool image" in Times bold with a size of 90 pixels at a distance of 20 pixels from the bottom of the base image, in yellow text (FFFF00):

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:color=>"#FFFF00", :overlay=>{:font_family=>"Times", :font_size=>90, :font_weight=>"bold", :text=>"Cool%2520image"}},
  {:flags=>"layer_apply", :gravity=>"south", :y=>20}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("color"=>"#FFFF00", "overlay"=>array("font_family"=>"Times", "font_size"=>90, "font_weight"=>"bold", "text"=>"Cool%2520image")),
  array("flags"=>"layer_apply", "gravity"=>"south", "y"=>20)
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      Overlay::source(
          Source::text('Cool%20image', (new TextStyle('Times', 90))
            ->fontWeight(FontWeight::bold()))
          ->textColor(Color::rgb('FFFF00')))
        ->position((new Position())
          ->gravity(Gravity::compass(Compass::south()))
          ->offsetY(20)
      
      ));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'color': "#FFFF00", 'overlay': {'font_family': "Times", 'font_size': 90, 'font_weight': "bold", 'text': "Cool%2520image"}},
  {'flags': "layer_apply", 'gravity': "south", 'y': 20}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {color: "#FFFF00", overlay: {font_family: "Times", font_size: 90, font_weight: "bold", text: "Cool%2520image"}},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .color("#FFFF00").overlay(new TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")).chain()
  .flags("layer_apply").gravity("south").y(20)).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {color: "#FFFF00", overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {color: "#FFFF00", overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation color="#FFFF00" overlay={{fontFamily: "Times", fontSize: 90, fontWeight: "bold", text: "Cool%2520image"}} />
  <Transformation flags="layer_apply" gravity="south" y="20" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation color="#FFFF00" :overlay="{fontFamily: 'Times', fontSize: 90, fontWeight: 'bold', text: 'Cool%2520image'}" />
  <cld-transformation flags="layer_apply" gravity="south" y="20" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation color="#FFFF00" overlay="text:Times_90_bold:Cool%2520image">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="south" y="20">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Color("#FFFF00").Overlay(new TextLayer().FontFamily("Times").FontSize(90).FontWeight("bold").Text("Cool%2520image")).Chain()
  .Flags("layer_apply").Gravity("south").Y(20)).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setColor("#FFFF00").setOverlay("text:Times_90_bold:Cool%2520image").chain()
  .setFlags("layer_apply").setGravity("south").setY(20)).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .color("#FFFF00").overlay(new TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")).chain()
  .flags("layer_apply").gravity("south").y(20)).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Cool%20image", TextStyle("Times", 90) {
fontWeight(FontWeight.bold())
}) {
textColor(Color.rgb("#FFFF00"))
}) {
position(Position {
gravity(Gravity.compass(Compass.south()))
offsetY(20)
})
})
}.generate()
Cool image text added to image

You can also use a 4-digit or 8-digit RGBA hex quadruplet for the color, where the 4th hex value represents the alpha (opacity) value (e.g., co_rgb:3e222240 results in 25% opacity).

The example below uses the same text string "Cool image" in Times bold with a size of 90 pixels at a distance of 20 pixels from the bottom of the base image, in yellow text, but this time with an opacity of 50% (FFFF0080):

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:color=>"#FFFF0080", :overlay=>{:font_family=>"Times", :font_size=>90, :font_weight=>"bold", :text=>"Cool%2520image"}},
  {:flags=>"layer_apply", :gravity=>"south", :y=>20}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("color"=>"#FFFF0080", "overlay"=>array("font_family"=>"Times", "font_size"=>90, "font_weight"=>"bold", "text"=>"Cool%2520image")),
  array("flags"=>"layer_apply", "gravity"=>"south", "y"=>20)
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      Overlay::source(
          Source::text('Cool%20image', (new TextStyle('Times', 90))
            ->fontWeight(FontWeight::bold()))
          ->textColor(Color::rgb('FFFF0080')))
        ->position((new Position())
          ->gravity(Gravity::compass(Compass::south()))
          ->offsetY(20)
      
      ));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'color': "#FFFF0080", 'overlay': {'font_family': "Times", 'font_size': 90, 'font_weight': "bold", 'text': "Cool%2520image"}},
  {'flags': "layer_apply", 'gravity': "south", 'y': 20}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {color: "#FFFF0080", overlay: {font_family: "Times", font_size: 90, font_weight: "bold", text: "Cool%2520image"}},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .color("#FFFF0080").overlay(new TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")).chain()
  .flags("layer_apply").gravity("south").y(20)).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {color: "#FFFF0080", overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {color: "#FFFF0080", overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")},
  {flags: "layer_apply", gravity: "south", y: 20}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation color="#FFFF0080" overlay={{fontFamily: "Times", fontSize: 90, fontWeight: "bold", text: "Cool%2520image"}} />
  <Transformation flags="layer_apply" gravity="south" y="20" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation color="#FFFF0080" :overlay="{fontFamily: 'Times', fontSize: 90, fontWeight: 'bold', text: 'Cool%2520image'}" />
  <cld-transformation flags="layer_apply" gravity="south" y="20" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation color="#FFFF0080" overlay="text:Times_90_bold:Cool%2520image">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="south" y="20">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Color("#FFFF0080").Overlay(new TextLayer().FontFamily("Times").FontSize(90).FontWeight("bold").Text("Cool%2520image")).Chain()
  .Flags("layer_apply").Gravity("south").Y(20)).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setColor("#FFFF0080").setOverlay("text:Times_90_bold:Cool%2520image").chain()
  .setFlags("layer_apply").setGravity("south").setY(20)).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .color("#FFFF0080").overlay(new TextLayer().fontFamily("Times").fontSize(90).fontWeight("bold").text("Cool%2520image")).chain()
  .flags("layer_apply").gravity("south").y(20)).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Cool%20image", TextStyle("Times", 90) {
fontWeight(FontWeight.bold())
}) {
textColor(Color.rgb("#FFFF0080"))
}) {
position(Position {
gravity(Gravity.compass(Compass.south()))
offsetY(20)
})
})
}.generate()
Cool image text added to image

Multi-line text

You can manually add multiple lines of text by separating each line of text with the newline character (%0A). For example, adding the text string "Cool image" in Verdana bold with a size of 50 pixels at a distance of 10 pixels from the left border of the base image, where each word appears on a new line:

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>{:font_family=>"Verdana", :font_size=>50, :font_weight=>"bold", :text=>"Cool%250Aimage"}},
  {:flags=>"layer_apply", :gravity=>"west", :x=>10}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>array("font_family"=>"Verdana", "font_size"=>50, "font_weight"=>"bold", "text"=>"Cool%250Aimage")),
  array("flags"=>"layer_apply", "gravity"=>"west", "x"=>10)
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      Overlay::source(
          Source::text('Cool%0Aimage', (new TextStyle('Verdana', 50))
            ->fontWeight(FontWeight::bold())))
        ->position((new Position())
          ->gravity(Gravity::compass(Compass::west()))
          ->offsetX(10)
      
      ));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': {'font_family': "Verdana", 'font_size': 50, 'font_weight': "bold", 'text': "Cool%250Aimage"}},
  {'flags': "layer_apply", 'gravity': "west", 'x': 10}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: {font_family: "Verdana", font_size: 50, font_weight: "bold", text: "Cool%250Aimage"}},
  {flags: "layer_apply", gravity: "west", x: 10}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Verdana").fontSize(50).fontWeight("bold").text("Cool%250Aimage")).chain()
  .flags("layer_apply").gravity("west").x(10)).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Verdana").fontSize(50).fontWeight("bold").text("Cool%250Aimage")},
  {flags: "layer_apply", gravity: "west", x: 10}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Verdana").fontSize(50).fontWeight("bold").text("Cool%250Aimage")},
  {flags: "layer_apply", gravity: "west", x: 10}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay={{fontFamily: "Verdana", fontSize: 50, fontWeight: "bold", text: "Cool%250Aimage"}} />
  <Transformation flags="layer_apply" gravity="west" x="10" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="{fontFamily: 'Verdana', fontSize: 50, fontWeight: 'bold', text: 'Cool%250Aimage'}" />
  <cld-transformation flags="layer_apply" gravity="west" x="10" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="text:Verdana_50_bold:Cool%250Aimage">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="west" x="10">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new TextLayer().FontFamily("Verdana").FontSize(50).FontWeight("bold").Text("Cool%250Aimage")).Chain()
  .Flags("layer_apply").Gravity("west").X(10)).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("text:Verdana_50_bold:Cool%250Aimage").chain()
  .setFlags("layer_apply").setGravity("west").setX(10)).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Verdana").fontSize(50).fontWeight("bold").text("Cool%250Aimage")).chain()
  .flags("layer_apply").gravity("west").x(10)).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Cool%0Aimage", TextStyle("Verdana", 50) {
fontWeight(FontWeight.bold())
})) {
position(Position {
gravity(Gravity.compass(Compass.west()))
offsetX(10)
})
})
}.generate()
Cool image text added to image

Auto-line breaks

Cloudinary also supports automatic multi-line text by defining a maximum width for the text string and adding the fit crop mode, which tells Cloudinary to automatically wrap the actual text content onto a new line once the width is reached.

Note
c_fit (textFit in SDK2s) is the only resize option that can be used as a qualifier of text overlays.

For example, to add a long text string in bold Neucha font with a size of 26 pixels to the base image that wraps at a width of 400 pixels:

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>{:font_family=>"Neucha", :font_size=>26, :font_weight=>"bold", :text=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, :width=>400, :crop=>"fit"},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>array("font_family"=>"Neucha", "font_size"=>26, "font_weight"=>"bold", "text"=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), "width"=>400, "crop"=>"fit"),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      Overlay::source(
          Source::text('Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.', (new TextStyle('Neucha', 26))
            ->fontWeight(FontWeight::bold()))
          ->transformation((new ImageTransformation())
            ->resize(Resize::fit()->width(400))
      
      )));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': {'font_family': "Neucha", 'font_size': 26, 'font_weight': "bold", 'text': "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, 'width': 400, 'crop': "fit"},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: {font_family: "Neucha", font_size: 26, font_weight: "bold", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, width: 400, crop: "fit"},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(400).crop("fit").chain()
  .flags("layer_apply")).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 400, crop: "fit"},
  {flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 400, crop: "fit"},
  {flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay={{fontFamily: "Neucha", fontSize: 26, fontWeight: "bold", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}} width="400" crop="fit" />
  <Transformation flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="{fontFamily: 'Neucha', fontSize: 26, fontWeight: 'bold', text: 'Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.'}" width="400" crop="fit" />
  <cld-transformation flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="text:Neucha_26_bold:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat." width="400" crop="fit">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new TextLayer().FontFamily("Neucha").FontSize(26).FontWeight("bold").Text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).Width(400).Crop("fit").Chain()
  .Flags("layer_apply")).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("text:Neucha_26_bold:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.").setWidth(400).setCrop("fit").chain()
  .setFlags("layer_apply")).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(400).crop("fit").chain()
  .flags("layer_apply")).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.", TextStyle("Neucha", 26) {
fontWeight(FontWeight.bold())
}) {
transformation(ImageTransformation {
resize(Resize.fit() {
width(400)
})
})
}))
}.generate()
Multi-line text string

When using the fit crop mode, you must specify a width for your text overlay, but height is optional. Line breaks are applied as needed to achieve the requested width and/or height rectangle.

The specified font size of your overlay stays as is, even if the resulting text overlay height exceeds the height of its hosting image. So, if you don't limit the overlay height, the height of the image expands to accommodate large texts:

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>{:font_family=>"Neucha", :font_size=>26, :font_weight=>"bold", :text=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, :width=>400, :crop=>"fit"},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>array("font_family"=>"Neucha", "font_size"=>26, "font_weight"=>"bold", "text"=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), "width"=>400, "crop"=>"fit"),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      
      Overlay::source(Source::text('Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.

Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.', (new TextStyle('Neucha', 26)
    )->fontWeight(FontWeight::bold()))
      ->transformation((new ImageTransformation())
        ->resize(Resize::fit()->width(400))
  )));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': {'font_family': "Neucha", 'font_size': 26, 'font_weight': "bold", 'text': "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, 'width': 400, 'crop': "fit"},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: {font_family: "Neucha", font_size: 26, font_weight: "bold", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, width: 400, crop: "fit"},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(400).crop("fit").chain()
  .flags("layer_apply")).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 400, crop: "fit"},
  {flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 400, crop: "fit"},
  {flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay={{fontFamily: "Neucha", fontSize: 26, fontWeight: "bold", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}} width="400" crop="fit" />
  <Transformation flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="{fontFamily: 'Neucha', fontSize: 26, fontWeight: 'bold', text: 'Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.'}" width="400" crop="fit" />
  <cld-transformation flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="text:Neucha_26_bold:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat." width="400" crop="fit">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new TextLayer().FontFamily("Neucha").FontSize(26).FontWeight("bold").Text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).Width(400).Crop("fit").Chain()
  .Flags("layer_apply")).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("text:Neucha_26_bold:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.").setWidth(400).setCrop("fit").chain()
  .setFlags("layer_apply")).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(400).crop("fit").chain()
  .flags("layer_apply")).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.

Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.", TextStyle("Neucha", 26) {
fontWeight(FontWeight.bold())
}) {
transformation(ImageTransformation {
resize(Resize.fit() {
width(400)
})
})
}))
}.generate()
Multi-line text no height limit

If you do limit the height of your overlay, any text that does not fit within the space defined is cut and an ellipsis (...) is added to the end of the text string to indicate that the text was truncated.

To define a maximum height for the multi-line text add the height parameter:

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>{:font_family=>"Neucha", :font_size=>26, :font_weight=>"bold", :text=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, :width=>400, :height=>250, :crop=>"fit"},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>array("font_family"=>"Neucha", "font_size"=>26, "font_weight"=>"bold", "text"=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), "width"=>400, "height"=>250, "crop"=>"fit"),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(
      
      Overlay::source(Source::text('Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.

Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.', (new TextStyle('Neucha', 26)
    )->fontWeight(FontWeight::bold()))
      ->transformation((new ImageTransformation())
        ->resize(Resize::fit()->width(400)->height(250))
  )));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': {'font_family': "Neucha", 'font_size': 26, 'font_weight': "bold", 'text': "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, 'width': 400, 'height': 250, 'crop': "fit"},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: {font_family: "Neucha", font_size: 26, font_weight: "bold", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, width: 400, height: 250, crop: "fit"},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(400).height(250).crop("fit").chain()
  .flags("layer_apply")).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 400, height: 250, crop: "fit"},
  {flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 400, height: 250, crop: "fit"},
  {flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay={{fontFamily: "Neucha", fontSize: 26, fontWeight: "bold", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}} width="400" height="250" crop="fit" />
  <Transformation flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="{fontFamily: 'Neucha', fontSize: 26, fontWeight: 'bold', text: 'Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.'}" width="400" height="250" crop="fit" />
  <cld-transformation flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="text:Neucha_26_bold:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat." width="400" height="250" crop="fit">
  </cl-transformation>
  <cl-transformation flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new TextLayer().FontFamily("Neucha").FontSize(26).FontWeight("bold").Text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).Width(400).Height(250).Crop("fit").Chain()
  .Flags("layer_apply")).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("text:Neucha_26_bold:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.").setWidth(400).setHeight(250).setCrop("fit").chain()
  .setFlags("layer_apply")).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().fontFamily("Neucha").fontSize(26).fontWeight("bold").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.%0D%0A%0D%0ALorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(400).height(250).crop("fit").chain()
  .flags("layer_apply")).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.

Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.", TextStyle("Neucha", 26) {
fontWeight(FontWeight.bold())
}) {
transformation(ImageTransformation {
resize(Resize.fit() {
width(400)
height(250)
})
})
}))
}.generate()
Multi-line text limited height

You can also set the text alignment and line spacing values to further control the text's appearance. Other resize parameters can be applied as an action over the entire overlay (before the fl_layer_apply) to resize the resulting the text-image overlay as a whole after it’s created.

For example, to add a long text string in center aligned bold Times font with a size of 14 pixels to the base image, that wraps at a width of 200 pixels and is limited to a height of 150 pixels; and then rotate the text by 9 degrees and set 30 pixels from the north border to better align with the underlying image:

Ruby:
Copy to clipboard
cl_image_tag("envelope.jpg", :transformation=>[
  {:width=>300, :crop=>"scale"},
  {:height=>150, :overlay=>{:font_family=>"Times", :font_size=>18, :font_weight=>"bold", :text_align=>"center", :text=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, :width=>200, :crop=>"fit"},
  {:angle=>9},
  {:flags=>"layer_apply", :gravity=>"north", :y=>30}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("envelope.jpg", array("transformation"=>array(
  array("width"=>300, "crop"=>"scale"),
  array("height"=>150, "overlay"=>array("font_family"=>"Times", "font_size"=>18, "font_weight"=>"bold", "text_align"=>"center", "text"=>"Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), "width"=>200, "crop"=>"fit"),
  array("angle"=>9),
  array("flags"=>"layer_apply", "gravity"=>"north", "y"=>30)
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('envelope.jpg'))
  ->resize(Resize::scale()->width(300))
  ->overlay(
      Overlay::source(
          Source::text('Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.', (new TextStyle('Times', 18))
            ->fontWeight(FontWeight::bold())
            ->textAlignment(TextAlignment::center()))
          ->transformation((new ImageTransformation())
            ->resize(Resize::fit()->width(200)->height(150))
            ->rotate(Rotate::byAngle(9))))
        ->position((new Position())
          ->gravity(Gravity::compass(Compass::north()))
          ->offsetY(30)
      
      ));
Python:
Copy to clipboard
CloudinaryImage("envelope.jpg").image(transformation=[
  {'width': 300, 'crop': "scale"},
  {'height': 150, 'overlay': {'font_family': "Times", 'font_size': 18, 'font_weight': "bold", 'text_align': "center", 'text': "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, 'width': 200, 'crop': "fit"},
  {'angle': 9},
  {'flags': "layer_apply", 'gravity': "north", 'y': 30}
  ])
Node.js:
Copy to clipboard
cloudinary.image("envelope.jpg", {transformation: [
  {width: 300, crop: "scale"},
  {height: 150, overlay: {font_family: "Times", font_size: 18, font_weight: "bold", text_align: "center", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}, width: 200, crop: "fit"},
  {angle: 9},
  {flags: "layer_apply", gravity: "north", y: 30}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(300).crop("scale").chain()
  .height(150).overlay(new TextLayer().fontFamily("Times").fontSize(18).fontWeight("bold").textAlign("center").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(200).crop("fit").chain()
  .angle(9).chain()
  .flags("layer_apply").gravity("north").y(30)).imageTag("envelope.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('envelope.jpg', {transformation: [
  {width: 300, crop: "scale"},
  {height: 150, overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(18).fontWeight("bold").textAlign("center").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 200, crop: "fit"},
  {angle: 9},
  {flags: "layer_apply", gravity: "north", y: 30}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("envelope.jpg", {transformation: [
  {width: 300, crop: "scale"},
  {height: 150, overlay: new cloudinary.TextLayer().fontFamily("Times").fontSize(18).fontWeight("bold").textAlign("center").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."), width: 200, crop: "fit"},
  {angle: 9},
  {flags: "layer_apply", gravity: "north", y: 30}
  ]})
React:
Copy to clipboard
<Image publicId="envelope.jpg" >
  <Transformation width="300" crop="scale" />
  <Transformation height="150" overlay={{fontFamily: "Times", fontSize: 18, fontWeight: "bold", textAlign: "center", text: "Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat."}} width="200" crop="fit" />
  <Transformation angle="9" />
  <Transformation flags="layer_apply" gravity="north" y="30" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="envelope.jpg" >
  <cld-transformation width="300" crop="scale" />
  <cld-transformation height="150" :overlay="{fontFamily: 'Times', fontSize: 18, fontWeight: 'bold', textAlign: 'center', text: 'Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.'}" width="200" crop="fit" />
  <cld-transformation angle="9" />
  <cld-transformation flags="layer_apply" gravity="north" y="30" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="envelope.jpg" >
  <cl-transformation width="300" crop="scale">
  </cl-transformation>
  <cl-transformation height="150" overlay="text:Times_18_bold_center:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat." width="200" crop="fit">
  </cl-transformation>
  <cl-transformation angle="9">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="north" y="30">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(300).Crop("scale").Chain()
  .Height(150).Overlay(new TextLayer().FontFamily("Times").FontSize(18).FontWeight("bold").TextAlign("center").Text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).Width(200).Crop("fit").Chain()
  .Angle(9).Chain()
  .Flags("layer_apply").Gravity("north").Y(30)).BuildImageTag("envelope.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(300).setCrop("scale").chain()
  .setHeight(150).setOverlay("text:Times_18_bold_center:Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.").setWidth(200).setCrop("fit").chain()
  .setAngle(9).chain()
  .setFlags("layer_apply").setGravity("north").setY(30)).generate("envelope.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(300).crop("scale").chain()
  .height(150).overlay(new TextLayer().fontFamily("Times").fontSize(18).fontWeight("bold").textAlign("center").text("Lorem%2520ipsum%2520dolor%2520sit%2520amet%2520consectetur%2520adipisicing%2520elit%2520sed%2520do%2520eiusmod%2520tempor%2520incididunt%2520ut%2520labore%2520et%2520dolore%2520magna%2520aliqua.%2520Ut%2520enim%2520ad%2520minim%2520veniam%2520quis%2520nostrud%2520exercitation%2520ullamco%2520laboris%2520nisi%2520ut%2520aliquip%2520ex%2520ea%2520commodo%2520consequat.")).width(200).crop("fit").chain()
  .angle(9).chain()
  .flags("layer_apply").gravity("north").y(30)).generate("envelope.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("envelope.jpg")
resize(Resize.scale() {
width(300)
})
overlay(Overlay.source(Source.text("Lorem%20ipsum%20dolor%20sit%20amet%20consectetur%20adipisicing%20elit%20sed%20do%20eiusmod%20tempor%20incididunt%20ut%20labore%20et%20dolore%20magna%20aliqua.%20Ut%20enim%20ad%20minim%20veniam%20quis%20nostrud%20exercitation%20ullamco%20laboris%20nisi%20ut%20aliquip%20ex%20ea%20commodo%20consequat.", TextStyle("Times", 18) {
fontWeight(FontWeight.bold())
textAlignment(TextAlignment.center())
}) {
transformation(ImageTransformation {
resize(Resize.fit() {
width(200)
height(150)
})
rotate(Rotate.byAngle(9))
})
}) {
position(Position {
gravity(Gravity.compass(Compass.north()))
offsetY(30)
})
})
}.generate()
Multi-line text limited with height

Special characters

Text strings containing special characters need to be modified (escaped) for use with the text overlay feature. This is relevant for any special characters that would not be allowed “as is” in a valid URL path, as well as other special Unicode characters. These text strings should be escaped using %-based UTF-8 encoding to ensure the text string is valid (for example, replace ? with %3F and use %20 for spaces between words). This encoding is done automatically when embedding images using the Cloudinary SDK helper methods and only needs to be done when manually building the asset delivery URL.

Additionally, to include a comma (,) forward slash (/), percent sign (%) or an emoji character in a text overlay, you must double-escape the % sign within those codes. For example:

Custom fonts

By default, only universally available fonts are supported for text overlays. However, if you want to use a non-standard font, you can upload it to your Cloudinary account as a raw, authenticated file and then specify the font's full public_id (including extension) as the font for your overlay:

Copy to clipboard
Cloudinary::Uploader.upload("AlexBrush-Regular.ttf", 
    resource_type: 'raw', # Custom fonts must be upload as 'raw'
    type: 'authenticated', # Custom fonts must be upload as 'authenticated'
    public_id: 'AlexBrush-Regular.ttf')

Ruby:
Copy to clipboard
cl_image_tag("fireworks.jpg", :transformation=>[
  {:color=>"white", :overlay=>{:font_family=>"ttf", :font_size=>100, :text=>"Happy%2520New%2520Year%2520%25202017%2520"}},
  {:flags=>"layer_apply", :gravity=>"north_west", :x=>30, :y=>30}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("fireworks.jpg", array("transformation"=>array(
  array("color"=>"white", "overlay"=>array("font_family"=>"ttf", "font_size"=>100, "text"=>"Happy%2520New%2520Year%2520%25202017%2520")),
  array("flags"=>"layer_apply", "gravity"=>"north_west", "x"=>30, "y"=>30)
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('fireworks.jpg'))
  ->overlay(
      Overlay::source(Source::text('Happy%20New%20Year%20%202017%20', (new TextStyle('AlexBrush-Regular.ttf', 100)))
        ->textColor(Color::WHITE))
      ->position((new Position())
        ->gravity(Gravity::compass(Compass::northWest()))
        ->offsetX(30)->offsetY(30)
  ));
Python:
Copy to clipboard
CloudinaryImage("fireworks.jpg").image(transformation=[
  {'color': "white", 'overlay': {'font_family': "ttf", 'font_size': 100, 'text': "Happy%2520New%2520Year%2520%25202017%2520"}},
  {'flags': "layer_apply", 'gravity': "north_west", 'x': 30, 'y': 30}
  ])
Node.js:
Copy to clipboard
cloudinary.image("fireworks.jpg", {transformation: [
  {color: "white", overlay: {font_family: "ttf", font_size: 100, text: "Happy%2520New%2520Year%2520%25202017%2520"}},
  {flags: "layer_apply", gravity: "north_west", x: 30, y: 30}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .color("white").overlay(new TextLayer().fontFamily("ttf").fontSize(100).text("Happy%2520New%2520Year%2520%25202017%2520")).chain()
  .flags("layer_apply").gravity("north_west").x(30).y(30)).imageTag("fireworks.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('fireworks.jpg', {transformation: [
  {color: "white", overlay: new cloudinary.TextLayer().fontFamily("ttf").fontSize(100).text("Happy%2520New%2520Year%2520%25202017%2520")},
  {flags: "layer_apply", gravity: "north_west", x: 30, y: 30}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("fireworks.jpg", {transformation: [
  {color: "white", overlay: new cloudinary.TextLayer().fontFamily("ttf").fontSize(100).text("Happy%2520New%2520Year%2520%25202017%2520")},
  {flags: "layer_apply", gravity: "north_west", x: 30, y: 30}
  ]})
React:
Copy to clipboard
<Image publicId="fireworks.jpg" >
  <Transformation color="white" overlay={{fontFamily: "ttf", fontSize: 100, text: "Happy%2520New%2520Year%2520%25202017%2520"}} />
  <Transformation flags="layer_apply" gravity="north_west" x="30" y="30" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="fireworks.jpg" >
  <cld-transformation color="white" :overlay="{fontFamily: 'ttf', fontSize: 100, text: 'Happy%2520New%2520Year%2520%25202017%2520'}" />
  <cld-transformation flags="layer_apply" gravity="north_west" x="30" y="30" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="fireworks.jpg" >
  <cl-transformation color="white" overlay="text:AlexBrush-Regular.ttf_100:Happy%2520New%2520Year%2520%25202017%2520">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="north_west" x="30" y="30">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Color("white").Overlay(new TextLayer().FontFamily("ttf").FontSize(100).Text("Happy%2520New%2520Year%2520%25202017%2520")).Chain()
  .Flags("layer_apply").Gravity("north_west").X(30).Y(30)).BuildImageTag("fireworks.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setColor("white").setOverlay("text:AlexBrush-Regular.ttf_100:Happy%2520New%2520Year%2520%25202017%2520").chain()
  .setFlags("layer_apply").setGravity("north_west").setX(30).setY(30)).generate("fireworks.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .color("white").overlay(new TextLayer().fontFamily("ttf").fontSize(100).text("Happy%2520New%2520Year%2520%25202017%2520")).chain()
  .flags("layer_apply").gravity("north_west").x(30).y(30)).generate("fireworks.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("fireworks.jpg")
overlay(Overlay.source(Source.text("Happy%20New%20Year%20%202017%20", TextStyle("AlexBrush-Regular.ttf", 100)) {
textColor(Color.WHITE)
}) {
position(Position {
gravity(Gravity.compass(Compass.northWest()))
offsetX(30)
offsetY(30)
})
})
}.generate()
Custom font overlay

Custom font guidelines

  • .ttf, .otf and .woff2 font types are supported.
  • Custom fonts must be uploaded as raw, authenticated files.

    Tip
    You can upload custom fonts via the Media Library by creating (or using an existing) signed upload preset where the Delivery type option in the preset is set as Authenticated. You can use this upload preset when uploading files to the Media Library by configuring it as the default Media library upload preset for Raw files.

    Raw, authenticated upload preset

    Alternatively, you can select the signed upload preset you create for custom fonts in the Media Library upload widget's Advanced settings while uploading assets, if that option is enabled for your account.

  • If your custom font is stored in a folder other than the root folder, specify the path using colons as separators. For example: folder1:folder2:myfont.ttf.

  • Make sure to include the file extension when referencing the public_id of the raw file. The extension must be specified in lower-case letters.

  • To make use of bold or italic font styles, upload separate font files for each emphasis style and specify the relevant file in the overlay transformation.

  • A custom font is available only to the specific account or sub-account where it was uploaded.

  • Underscores are not supported in custom font names. When uploading the font as a raw file, make sure the public_id does not include an underscore.

  • As with any asset you upload to Cloudinary, it is your responsibility to make sure you have the necessary license and redistribution rights for any custom fonts you use.

Predefined text templates

Instead of specifying the styling parameters every time you need to dynamically add a text overlay to an image, you can use the Public ID of a text image created with the text method of the upload API. The same styles that were used to create the text image will also be dynamically applied to the text overlay. The default text string of the text image is also used unless you provide a new text string, which can be useful if you don't want the text string to appear in the URL, or if the text string is very long.

For example, adding the text string "Stylish text" using the same styling applied in creating the text image named sample_text_style (Roboto font, 82 size, bold and red):

Ruby:
Copy to clipboard
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>{:public_id=>"sample_text_style", :text=>"Stylish%20text"}},
  {:flags=>"layer_apply", :gravity=>"south"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>array("public_id"=>"sample_text_style", "text"=>"Stylish%20text")),
  array("flags"=>"layer_apply", "gravity"=>"south")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('flowers.jpg'))
  ->resize(Resize::scale()->width(500))
  ->overlay(Overlay::source(Source::text('Stylish text', (new TextStyle('sample', 'text'))))
    ->position((new Position())
      ->gravity(Gravity::compass(Compass::south()))));
Python:
Copy to clipboard
CloudinaryImage("flowers.jpg").image(transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': {'public_id': "sample_text_style", 'text': "Stylish%20text"}},
  {'flags': "layer_apply", 'gravity': "south"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: {public_id: "sample_text_style", text: "Stylish%20text"}},
  {flags: "layer_apply", gravity: "south"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().text("Stylish%20text").publicId("sample_text_style")).chain()
  .flags("layer_apply").gravity("south")).imageTag("flowers.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('flowers.jpg', {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().text("Stylish%20text").publicId("sample_text_style")},
  {flags: "layer_apply", gravity: "south"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.TextLayer().text("Stylish%20text").publicId("sample_text_style")},
  {flags: "layer_apply", gravity: "south"}
  ]})
React:
Copy to clipboard
<Image publicId="flowers.jpg" >
  <Transformation width="500" crop="scale" />
  <Transformation overlay={{text: "Stylish%20text", publicId: "sample_text_style"}} />
  <Transformation flags="layer_apply" gravity="south" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="flowers.jpg" >
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="{text: 'Stylish%20text', publicId: 'sample_text_style'}" />
  <cld-transformation flags="layer_apply" gravity="south" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="flowers.jpg" >
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="text:sample_text_style:Stylish%20text">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="south">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new TextLayer().Text("Stylish%20text").PublicId("sample_text_style")).Chain()
  .Flags("layer_apply").Gravity("south")).BuildImageTag("flowers.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("text:sample_text_style:Stylish%20text").chain()
  .setFlags("layer_apply").setGravity("south")).generate("flowers.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new TextLayer().text("Stylish%20text").publicId("sample_text_style")).chain()
  .flags("layer_apply").gravity("south")).generate("flowers.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
publicId("flowers.jpg")
resize(Resize.scale() {
width(500)
})
overlay(Overlay.source(Source.text("Stylish text", TextStyle("sample", "text"))) {
position(Position {
gravity(Gravity.compass(Compass.south()))
})
})
}.generate()
Cool image text added to image

Text layer flags

The text content for text layers is often supplied in real time by your application users or another external source. You may want to use the following flags to help handle these scenarios:

  • fl_disallow_overflow: As mentioned in layer overflow behavior above, you can control whether large image or text layers will result in expanding the size of the delivered asset using the fl_no_overflow flag.

    However, for text overlays, if you don't want long text to impact the expected delivery asset size, but an unexpected trim might risk cutting off essential text, you can apply the fl_disallow_overflow flag, which will cause URLs with overflowing text layers to fail and return a 400 (bad request) error that you can check for and handle in your application.

    For more details and examples, see fl_no_overflow and fl_disallow_overflow in the Transformation Reference.

  • fl_text_no_trim: By default, text layers are tightly trimmed on all sides. In some cases, especially if you add a border around the text, or you are using a gravity for your text layer that might place the text too close to the edge of the layer behind it, you can use the fl_text_no_trim flag to add a small amount of padding around the the text overlay string. For example:

    Ruby:
    Copy to clipboard
    cl_image_tag("flower.jpg", :transformation=>[
      {:color=>"yellow", :overlay=>{:font_family=>"Arial", :font_size=>150, :text=>"Flowers"}, :flags=>"text_no_trim"},
      {:border=>"6px_solid_red"},
      {:flags=>"layer_apply"}
      ])
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("flower.jpg", array("transformation"=>array(
      array("color"=>"yellow", "overlay"=>array("font_family"=>"Arial", "font_size"=>150, "text"=>"Flowers"), "flags"=>"text_no_trim"),
      array("border"=>"6px_solid_red"),
      array("flags"=>"layer_apply")
      )))
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('flower.jpg'))
      ->overlay(
          Overlay::source(Source::text('Flowers', (new TextStyle('Arial', 150)))
            ->textColor(Color::YELLOW)
            ->transformation((new ImageTransformation())
              ->addFlag(Flag::textNoTrim())
              ->border(Border::solid(6, Color::RED))
      )));
    Python:
    Copy to clipboard
    CloudinaryImage("flower.jpg").image(transformation=[
      {'color': "yellow", 'overlay': {'font_family': "Arial", 'font_size': 150, 'text': "Flowers"}, 'flags': "text_no_trim"},
      {'border': "6px_solid_red"},
      {'flags': "layer_apply"}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("flower.jpg", {transformation: [
      {color: "yellow", overlay: {font_family: "Arial", font_size: 150, text: "Flowers"}, flags: "text_no_trim"},
      {border: "6px_solid_red"},
      {flags: "layer_apply"}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .color("yellow").overlay(new TextLayer().fontFamily("Arial").fontSize(150).text("Flowers")).flags("text_no_trim").chain()
      .border("6px_solid_red").chain()
      .flags("layer_apply")).imageTag("flower.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('flower.jpg', {transformation: [
      {color: "yellow", overlay: new cloudinary.TextLayer().fontFamily("Arial").fontSize(150).text("Flowers"), flags: "text_no_trim"},
      {border: "6px_solid_red"},
      {flags: "layer_apply"}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("flower.jpg", {transformation: [
      {color: "yellow", overlay: new cloudinary.TextLayer().fontFamily("Arial").fontSize(150).text("Flowers"), flags: "text_no_trim"},
      {border: "6px_solid_red"},
      {flags: "layer_apply"}
      ]})
    React:
    Copy to clipboard
    <Image publicId="flower.jpg" >
      <Transformation color="yellow" overlay={{fontFamily: "Arial", fontSize: 150, text: "Flowers"}} flags="text_no_trim" />
      <Transformation border="6px_solid_red" />
      <Transformation flags="layer_apply" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="flower.jpg" >
      <cld-transformation color="yellow" :overlay="{fontFamily: 'Arial', fontSize: 150, text: 'Flowers'}" flags="text_no_trim" />
      <cld-transformation border="6px_solid_red" />
      <cld-transformation flags="layer_apply" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="flower.jpg" >
      <cl-transformation color="yellow" overlay="text:Arial_150:Flowers" flags="text_no_trim">
      </cl-transformation>
      <cl-transformation border="6px_solid_red">
      </cl-transformation>
      <cl-transformation flags="layer_apply">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Color("yellow").Overlay(new TextLayer().FontFamily("Arial").FontSize(150).Text("Flowers")).Flags("text_no_trim").Chain()
      .Border("6px_solid_red").Chain()
      .Flags("layer_apply")).BuildImageTag("flower.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setColor("yellow").setOverlay("text:Arial_150:Flowers").setFlags("text_no_trim").chain()
      .setBorder("6px_solid_red").chain()
      .setFlags("layer_apply")).generate("flower.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .color("yellow").overlay(new TextLayer().fontFamily("Arial").fontSize(150).text("Flowers")).flags("text_no_trim").chain()
      .border("6px_solid_red").chain()
      .flags("layer_apply")).generate("flower.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
    publicId("flower.jpg")
    overlay(Overlay.source(Source.text("Flowers", TextStyle("Arial", 150)) {
    textColor(Color.YELLOW)
    transformation(ImageTransformation {
    addFlag(Flag.textNoTrim())
    border(Border.solid(6, Color.RED))
    })
    }))
    }.generate()
    Text with padding

    Note
    When placing a background behind text overlays (e.g., l_text:Arial_100:Flowers,b_green), Cloudinary automatically adds this padding, so this padding flag isn't necessary.

Adding image underlays

Add an underlay image under a base partially-transparent image or video with the underlay parameter (u in URLs) and the public ID of a previously uploaded image (e.g., u_background for an image with the public ID of background). You can determine the dimension of the underlay using width, height, and the x and y parameters, and adjust the location of the base image over the underlay using the gravity parameter. The underlay can also be further transformed like any other image uploaded to Cloudinary, and the underlay parameter supports the same features as for overlays.

For example, adding an underlay of an image called site_bg to the base image. The underlay and base image are both resized to the same width and height, and the brightness is increased to 100 using the brightness effect:

Ruby:
Copy to clipboard
cl_image_tag("smartphone.png", :transformation=>[
  {:height=>200, :width=>200, :crop=>"fill"},
  {:underlay=>"site_bg"},
  {:height=>200, :width=>200, :crop=>"scale"},
  {:effect=>"brightness:100"},
  {:flags=>"layer_apply"}
  ])
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("smartphone.png", array("transformation"=>array(
  array("height"=>200, "width"=>200, "crop"=>"fill"),
  array("underlay"=>"site_bg"),
  array("height"=>200, "width"=>200, "crop"=>"scale"),
  array("effect"=>"brightness:100"),
  array("flags"=>"layer_apply")
  )))
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('smartphone.png'))
  ->resize(Resize::fill()->width(200)->height(200))
  ->underlay(
      Underlay::source(Source::image('site_bg')
        ->transformation((new ImageTransformation())
          ->resize(Resize::scale()->width(200)->height(200))
          ->adjust(Adjust::brightness()->level(100))
  )));
Python:
Copy to clipboard
CloudinaryImage("smartphone.png").image(transformation=[
  {'height': 200, 'width': 200, 'crop': "fill"},
  {'underlay': "site_bg"},
  {'height': 200, 'width': 200, 'crop': "scale"},
  {'effect': "brightness:100"},
  {'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("smartphone.png", {transformation: [
  {height: 200, width: 200, crop: "fill"},
  {underlay: "site_bg"},
  {height: 200, width: 200, crop: "scale"},
  {effect: "brightness:100"},
  {flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .height(200).width(200).crop("fill").chain()
  .underlay(new Layer().publicId("site_bg")).chain()
  .height(200).width(200).crop("scale").chain()
  .effect("brightness:100").chain()
  .flags("layer_apply")).imageTag("smartphone.png");
JS:
Copy to clipboard
cloudinary.imageTag('smartphone.png', {transformation: [
  {height: 200, width: 200, crop: "fill"},
  {underlay: new cloudinary.Layer().publicId("site_bg")},
  {height: 200, width: 200, crop: "scale"},
  {effect: "brightness:100"},
  {flags: "layer_apply"}
  ]}).toHtml();