Visual image effects and enhancements

Cloudinary supports a large number of effects and enhancements that can be applied to change the visual appearance of delivered images. You can also apply multiple effects to an image by applying each effect as a separate chained transformation.

Overview

Cloudinary's visual effects and enhancements are a great way to easily change the way your images look within your site or application. For example, you can change the shape of your images, blur and pixelate them, apply quality improvements, make color adjustments, change the look and feel with fun effects, apply filters, and much more.

Some transformations use fairly simple syntax, whereas others require more explanation - examples of these types of transformations are shown in the advanced syntax examples.

Besides the examples on this page, there are many more effects available and you can find a full list of them, including examples, by checking out our URL transformation reference.

Here are some popular options for using effects and artistic enhancements. Click each image to see the URL parameters applied in each case:

Cartoonify your images Cartoonify
your images
Add a vignette to your images Add a vignette to
your images
Create low quality image placeholders Generate low quality
image placeholders
Add image outlines Add image
outlines

Simple syntax examples

Here are some examples of effects and enhancements that use a simple transformation syntax. Click the links to see the full syntax for each transformation in the URL transformation reference.

Artistic filters

Apply an artistic filter using the art effect, specifying one of the filters shown.

Available filters

Original image:

Original image, no filter

Filters:

al_dente artistic filter al_dente athena artistic filter athena audrey artistic filter audrey aurora artistic filter aurora daguerre artistic filter daguerre eucalyptus artistic filter eucalyptus fes artistic filter fes frost artistic filter frost hairspray artistic filter hairspray hokusai artistic filter hokusai incognito artistic filter incognito linen artistic filter linen peacock artistic filter peacock primavera artistic filter primavera quartz artistic filter quartz red_rock artistic filter red_rock refresh artistic filter refresh sizzle artistic filter sizzle sonnet artistic filter sonnet ukulele artistic filter ukulele zorro artistic filter zorro

Ruby:
Copy to clipboard
cl_image_tag("horses.jpg", :effect=>"art:zorro")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('horses.jpg'))
  ->effect(Effect::artisticFilter(
  ArtisticFilter::zorro()));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("horses.jpg", array("effect"=>"art:zorro"))
Python:
Copy to clipboard
CloudinaryImage("horses.jpg").image(effect="art:zorro")
Node.js:
Copy to clipboard
cloudinary.image("horses.jpg", {effect: "art:zorro"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("art:zorro")).imageTag("horses.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("horses.jpg").effect(artisticFilter("zorro"));
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('horses.jpg', {effect: "art:zorro"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("horses.jpg", {effect: "art:zorro"})
React:
Copy to clipboard
<Image publicId="horses.jpg" >
  <Transformation effect="art:zorro" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="horses.jpg" >
  <cld-transformation effect="art:zorro" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="horses.jpg" >
  <cl-transformation effect="art:zorro">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("art:zorro")).BuildImageTag("horses.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("art:zorro")).generate("horses.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("art:zorro")).generate("horses.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("horses.jpg")
   effect(Effect.artisticFilter(
  ArtisticFilter.zorro())) 
}.generate()

See full syntax: e_art in the Transformation Reference.

Cartoonify

Make an image look more like a cartoon using the cartoonify effect.

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

See full syntax: e_cartoonify in the Transformation Reference.

Opacity

Adjust the opacity of an image using the opacity transformation (o in URLs). Specify a value between 0 and 100, representing the percentage of transparency, where 100 means completely opaque and 0 is completely transparent. In this case the image is delivered with 30% opacity:

Ruby:
Copy to clipboard
cl_image_tag("horses.jpg", :opacity=>30)
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('horses.jpg'))
  ->adjust(Adjust::opacity(30));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("horses.jpg", array("opacity"=>30))
Python:
Copy to clipboard
CloudinaryImage("horses.jpg").image(opacity=30)
Node.js:
Copy to clipboard
cloudinary.image("horses.jpg", {opacity: 30})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().opacity(30)).imageTag("horses.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("horses.jpg").adjust(opacity(30));
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('horses.jpg', {opacity: 30}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("horses.jpg", {opacity: 30})
React:
Copy to clipboard
<Image publicId="horses.jpg" >
  <Transformation opacity="30" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="horses.jpg" >
  <cld-transformation opacity="30" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="horses.jpg" >
  <cl-transformation opacity="30">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Opacity(30)).BuildImageTag("horses.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setOpacity(30)).generate("horses.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().opacity(30)).generate("horses.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("horses.jpg")
   adjust(Adjust.opacity(30)) 
}.generate()
Image delivered with 30% opacity

See full syntax: o (opacity) in the Transformation Reference.

Pixelate

Pixelate an image using the pixelate effect.

Ruby:
Copy to clipboard
cl_image_tag("horses.jpg", :effect=>"pixelate:20")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('horses.jpg'))
  ->effect(Effect::pixelate()->squareSize(20));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("horses.jpg", array("effect"=>"pixelate:20"))
Python:
Copy to clipboard
CloudinaryImage("horses.jpg").image(effect="pixelate:20")
Node.js:
Copy to clipboard
cloudinary.image("horses.jpg", {effect: "pixelate:20"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("pixelate:20")).imageTag("horses.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("horses.jpg").effect(pixelate().squareSize(20));
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('horses.jpg', {effect: "pixelate:20"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("horses.jpg", {effect: "pixelate:20"})
React:
Copy to clipboard
<Image publicId="horses.jpg" >
  <Transformation effect="pixelate:20" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="horses.jpg" >
  <cld-transformation effect="pixelate:20" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="horses.jpg" >
  <cl-transformation effect="pixelate:20">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("pixelate:20")).BuildImageTag("horses.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("pixelate:20")).generate("horses.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("pixelate:20")).generate("horses.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("horses.jpg")
   effect(Effect.pixelate() { squareSize(20) }) 
}.generate()
Pixelated image

See full syntax: e_pixelate in the Transformation Reference.

Sepia

Change the colors of an image to shades of sepia using the sepia effect.

Ruby:
Copy to clipboard
cl_image_tag("horses.jpg", :effect=>"sepia")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('horses.jpg'))
  ->effect(Effect::sepia());
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("horses.jpg", array("effect"=>"sepia"))
Python:
Copy to clipboard
CloudinaryImage("horses.jpg").image(effect="sepia")
Node.js:
Copy to clipboard
cloudinary.image("horses.jpg", {effect: "sepia"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("sepia")).imageTag("horses.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("horses.jpg").effect(sepia());
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('horses.jpg', {effect: "sepia"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("horses.jpg", {effect: "sepia"})
React:
Copy to clipboard
<Image publicId="horses.jpg" >
  <Transformation effect="sepia" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="horses.jpg" >
  <cld-transformation effect="sepia" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="horses.jpg" >
  <cl-transformation effect="sepia">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("sepia")).BuildImageTag("horses.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("sepia")).generate("horses.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("sepia")).generate("horses.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("horses.jpg")
   effect(Effect.sepia()) 
}.generate()
Sepia effect applied to an image

See full syntax: e_sepia in the Transformation Reference.

Vignette

Fade the edges of an image into the background using the vignette effect.

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

See full syntax: e_vignette in the Transformation Reference.

Advanced syntax examples

In general, most of the visual effects and enhancements can take an additional option to tailor the effect to your liking. For some, however, you may need to provide additional syntax and use some more complex concepts. It is important to understand how these advanced transformations work when attempting to use them. The sections below outline some of the more advanced transformations and help you to use these with your own assets.

Remember, there are many more transformations available and you can find a full list of them, including examples, by checking out our URL transformation reference.

3D LUTs

3D lookup tables (3D LUTs) are used to map one color space to another. They can be used to adjust colors, contrast, and/or saturation, so that you can correct contrast, fix a camera’s inability to see a particular color shade, or give a final finished look or a particular style to your image.

After uploading a .3dl file to your account as a raw file, you can apply it to any image using the lut property of the layer parameter ( l_lut: in URLs), followed by the LUT file name (including the .3dl extension).

Below you can see the laydybug_top.jpg image file in its original color, compared to the video with different LUT files applied. Below these is the code for applying one of the LUTs.

Original Original image with iwltbap_sedona LUT with 'iwltbap_sedona' LUT image with iwltbap_aspen LUT with 'iwltbap_aspen' LUT

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

See full syntax: l_lut in the Transformation Reference.

Background color

Use the background parameter (b in URLs) to set the background color of the image. The image background is visible when padding is added with one of the padding crop modes, when rounding corners, when adding overlays, and with semi-transparent PNGs and GIFs.

An opaque color can be set as an RGB hex triplet (e.g., b_rgb:3e2222), a 3-digit RGB hex (e.g., b_rgb:777) or a named color (e.g., b_green). Cloudinary's client libraries also support a # shortcut for RGB (e.g., setting background to #3e2222 which is then translated to rgb:3e2222).

For example, the uploaded image named sample padded to a width and height of 300 pixels with a green background:

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :background=>"green", :height=>300, :width=>300, :crop=>"pad")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->resize(Resize::pad()->width(300)
->height(300)
  ->background(
  Background::color(Color::GREEN))
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("background"=>"green", "height"=>300, "width"=>300, "crop"=>"pad"))
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(background="green", height=300, width=300, crop="pad")
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {background: "green", height: 300, width: 300, crop: "pad"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().background("green").height(300).width(300).crop("pad")).imageTag("sample.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("sample.jpg").resize(
  pad()
    .width(300)
    .height(300)
    .background(color("green"))
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample.jpg', {background: "green", height: 300, width: 300, crop: "pad"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {background: "green", height: 300, width: 300, crop: "pad"})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation background="green" height="300" width="300" crop="pad" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation background="green" height="300" width="300" crop="pad" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation background="green" height="300" width="300" crop="pad">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Background("green").Height(300).Width(300).Crop("pad")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setBackground("green").setHeight(300).setWidth(300).setCrop("pad")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().background("green").height(300).width(300).crop("pad")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("sample.jpg")
   resize(Resize.pad() { width(300)
 height(300)
   background(
  Background.color(Color.GREEN))
   }) 
}.generate()
Image padded to a width and height of 300 pixels with green background

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

Note
When using the background parameter to set the background color of a text overlay, you can also set the color to predominant_contrast. This selects the strongest contrasting color to the predominant color while taking all pixels in the image into account. For example, l_text:Arial_30:foo,b_predominant_contrast.

See full syntax: b (background) in the Transformation Reference.

Content-aware padding

You can automatically set the background color to the most prominent color in the image when applying one of the padding crop modes (pad, lpad, or mpad) by setting the background parameter to auto (b_auto in URLs). The parameter can also accept an additional value as follows:

  • b_auto:border - selects the predominant color while taking only the image border pixels into account. This is the default option for b_auto.
  • b_auto:predominant - selects the predominant color while taking all pixels in the image into account.
  • b_auto:border_contrast - selects the strongest contrasting color to the predominant color while taking only the image border pixels into account.
  • b_auto:predominant_contrast - selects the strongest contrasting color to the predominant color while taking all pixels in the image into account.
border b_auto:border predominant b_auto:predominant border_contrast b_auto:border_contrast predominant_contrast b_auto:predominant_contrast

For example, padding the sample image to a width and height of 300 pixels, and with the background color set to the predominant color in the image:

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :background=>"auto:predominant", :height=>300, :width=>300, :crop=>"pad")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->resize(Resize::pad()->width(300)
->height(300)
  ->background(
  Background::predominant())
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("background"=>"auto:predominant", "height"=>300, "width"=>300, "crop"=>"pad"))
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(background="auto:predominant", height=300, width=300, crop="pad")
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {background: "auto:predominant", height: 300, width: 300, crop: "pad"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().background("auto:predominant").height(300).width(300).crop("pad")).imageTag("sample.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("sample.jpg").resize(
  pad()
    .width(300)
    .height(300)
    .background(predominant())
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample.jpg', {background: "auto:predominant", height: 300, width: 300, crop: "pad"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {background: "auto:predominant", height: 300, width: 300, crop: "pad"})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation background="auto:predominant" height="300" width="300" crop="pad" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation background="auto:predominant" height="300" width="300" crop="pad" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation background="auto:predominant" height="300" width="300" crop="pad">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Background("auto:predominant").Height(300).Width(300).Crop("pad")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setBackground("auto:predominant").setHeight(300).setWidth(300).setCrop("pad")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().background("auto:predominant").height(300).width(300).crop("pad")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("sample.jpg")
   resize(Resize.pad() { width(300)
 height(300)
   background(
  Background.predominant())
   }) 
}.generate()
Pad to 300x300 with the predominant color set as the background color

See full syntax: b_auto in the Transformation Reference.

Gradient fade

You can also apply a padding gradient fade effect with the predominant colors in the image by adjusting the value of the b_auto parameter as follows:

b_auto:[gradient_type]:[number]:[direction]

Where:

  • gradient_type - one of the following values:
    • predominant_gradient - base the gradient fade effect on the predominant colors in the image
    • predominant_gradient_contrast - base the effect on the colors that contrast the predominant colors in the image
    • border_gradient - base the gradient fade effect on the predominant colors in the border pixels of the image
    • border_gradient_contrast - base the effect on the colors that contrast the predominant colors in the border pixels of the image
  • number - the number of predominant colors to select. Possible values: 2 or 4. Default: 2
  • direction - if 2 colors are selected, this parameter specifies the direction to blend the 2 colors together (if 4 colors are selected each gets interpolated between the four corners). Possible values: horizontal, vertical, diagonal_desc, and diagonal_asc. Default: horizontal
predominant predominant_gradient:2:diagonal_desc border_contrast predominant_gradient_contrast:4

Ruby:
Copy to clipboard
cl_image_tag("horse.jpg", :background=>"auto:predominant_gradient_contrast:4", :height=>300, :width=>300, :crop=>"pad")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('horse.jpg'))
  ->resize(Resize::pad()->width(300)
->height(300)
  ->background(
  Background::predominantGradient()
  ->contrast()
  ->gradientColors(4)
  )
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("horse.jpg", array("background"=>"auto:predominant_gradient_contrast:4", "height"=>300, "width"=>300, "crop"=>"pad"))
Python:
Copy to clipboard
CloudinaryImage("horse.jpg").image(background="auto:predominant_gradient_contrast:4", height=300, width=300, crop="pad")
Node.js:
Copy to clipboard
cloudinary.image("horse.jpg", {background: "auto:predominant_gradient_contrast:4", height: 300, width: 300, crop: "pad"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().background("auto:predominant_gradient_contrast:4").height(300).width(300).crop("pad")).imageTag("horse.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("horse.jpg").resize(
  pad()
    .width(300)
    .height(300)
    .background(
      predominantGradient()
        .contrast()
        .gradientColors(4)
    )
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('horse.jpg', {background: "auto:predominant_gradient_contrast:4", height: 300, width: 300, crop: "pad"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("horse.jpg", {background: "auto:predominant_gradient_contrast:4", height: 300, width: 300, crop: "pad"})
React:
Copy to clipboard
<Image publicId="horse.jpg" >
  <Transformation background="auto:predominant_gradient_contrast:4" height="300" width="300" crop="pad" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="horse.jpg" >
  <cld-transformation background="auto:predominant_gradient_contrast:4" height="300" width="300" crop="pad" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="horse.jpg" >
  <cl-transformation background="auto:predominant_gradient_contrast:4" height="300" width="300" crop="pad">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Background("auto:predominant_gradient_contrast:4").Height(300).Width(300).Crop("pad")).BuildImageTag("horse.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setBackground("auto:predominant_gradient_contrast:4").setHeight(300).setWidth(300).setCrop("pad")).generate("horse.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().background("auto:predominant_gradient_contrast:4").height(300).width(300).crop("pad")).generate("horse.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("horse.jpg")
   resize(Resize.pad() { width(300)
 height(300)
   background(
  Background.predominantGradient() {
   contrast()
   gradientColors(4)
   })
   }) 
}.generate()

Custom color palette

Add a custom palette to limit the selected color to one of the colors in the palette that you provide. Once the predominant color has been calculated then the closest color from the available palette is selected. Append a colon and then the value palette followed by a list of colors, each separated by an underscore. For example, to automatically add padding and a palette that limits the possible choices to green, red and blue: b_auto:palette_red_green_blue

The palette can be used in combination with any of the various values for b_auto, and the same color in the palette can be selected more than once when requesting multiple predominant colors. For example, padding to a width and height of 300 pixels, with a 4 color gradient fade in the auto colored padding, and limiting the possible colors to red, green, blue, and orange:

Ruby:
Copy to clipboard
cl_image_tag("horse.jpg", :background=>"auto:predominant_gradient:4:palette_red_green_blue_orange", :height=>300, :width=>300, :crop=>"pad")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('horse.jpg'))
  ->resize(Resize::pad()->width(300)
->height(300)
  ->background(
  Background::predominantGradient()->gradientColors(4)
  ->palette(Color::RED,Color::GREEN,Color::BLUE,Color::ORANGE)
  )
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("horse.jpg", array("background"=>"auto:predominant_gradient:4:palette_red_green_blue_orange", "height"=>300, "width"=>300, "crop"=>"pad"))
Python:
Copy to clipboard
CloudinaryImage("horse.jpg").image(background="auto:predominant_gradient:4:palette_red_green_blue_orange", height=300, width=300, crop="pad")
Node.js:
Copy to clipboard
cloudinary.image("horse.jpg", {background: "auto:predominant_gradient:4:palette_red_green_blue_orange", height: 300, width: 300, crop: "pad"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().background("auto:predominant_gradient:4:palette_red_green_blue_orange").height(300).width(300).crop("pad")).imageTag("horse.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("horse.jpg").resize(
  pad()
    .width(300)
    .height(300)
    .background(
      predominantGradient()
        .gradientColors(4)
        .palette("red", "green", "blue", "orange")
    )
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('horse.jpg', {background: "auto:predominant_gradient:4:palette_red_green_blue_orange", height: 300, width: 300, crop: "pad"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("horse.jpg", {background: "auto:predominant_gradient:4:palette_red_green_blue_orange", height: 300, width: 300, crop: "pad"})
React:
Copy to clipboard
<Image publicId="horse.jpg" >
  <Transformation background="auto:predominant_gradient:4:palette_red_green_blue_orange" height="300" width="300" crop="pad" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="horse.jpg" >
  <cld-transformation background="auto:predominant_gradient:4:palette_red_green_blue_orange" height="300" width="300" crop="pad" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="horse.jpg" >
  <cl-transformation background="auto:predominant_gradient:4:palette_red_green_blue_orange" height="300" width="300" crop="pad">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Background("auto:predominant_gradient:4:palette_red_green_blue_orange").Height(300).Width(300).Crop("pad")).BuildImageTag("horse.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setBackground("auto:predominant_gradient:4:palette_red_green_blue_orange").setHeight(300).setWidth(300).setCrop("pad")).generate("horse.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().background("auto:predominant_gradient:4:palette_red_green_blue_orange").height(300).width(300).crop("pad")).generate("horse.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("horse.jpg")
   resize(Resize.pad() { width(300)
 height(300)
   background(
  Background.predominantGradient() { gradientColors(4)
   palette(Color.RED,Color.GREEN,Color.BLUE,Color.ORANGE)
   })
   }) 
}.generate()
Pad to 300x300 with 4 color gradient fade from given palette

Gradient fade into padding

Fade the image into the added padding by adding the gradient_fade effect with a value of symmetric_pad (e_gradient_fade:symmetric_pad in URLs). The padding blends into the edge of the image with a strength indicated by an additional value, separated by a colon (Range: 0 to 100, Default: 20). Values for x and y can also be specified as a percentage (range: 0.0 to 1.0), or in pixels (integer values) to indicate how far into the image to apply the gradient effect. By default, the gradient is applied 30% into the image (x_0.3).

For example, padding the sample image to a width and height of 300 pixels, with the background color set to the predominant color, and with a gradient fade effect, between the added padding and 50% into the image.

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :transformation=>[
  {:background=>"auto:predominant", :height=>300, :width=>300, :crop=>"pad"},
  {:effect=>"gradient_fade:symmetric_pad", :x=>0.5}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->resize(Resize::pad()->width(300)
->height(300)
  ->background(
  Background::predominant())
  )
  ->effect(Effect::gradientFade()
  ->type(
  GradientFade::symmetricPad())
->horizontalStartPoint(0.5));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("background"=>"auto:predominant", "height"=>300, "width"=>300, "crop"=>"pad"),
  array("effect"=>"gradient_fade:symmetric_pad", "x"=>"0.5")
  )))
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(transformation=[
  {'background': "auto:predominant", 'height': 300, 'width': 300, 'crop': "pad"},
  {'effect': "gradient_fade:symmetric_pad", 'x': "0.5"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {transformation: [
  {background: "auto:predominant", height: 300, width: 300, crop: "pad"},
  {effect: "gradient_fade:symmetric_pad", x: "0.5"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .background("auto:predominant").height(300).width(300).crop("pad").chain()
  .effect("gradient_fade:symmetric_pad").x(0.5)).imageTag("sample.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("sample.jpg")
  .resize(
    pad()
      .width(300)
      .height(300)
      .background(predominant())
  )
  .effect(
    gradientFade()
      .type(symmetricPad())
      .horizontalStartPoint(0.5)
  );
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample.jpg', {transformation: [
  {background: "auto:predominant", height: 300, width: 300, crop: "pad"},
  {effect: "gradient_fade:symmetric_pad", x: "0.5"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {transformation: [
  {background: "auto:predominant", height: 300, width: 300, crop: "pad"},
  {effect: "gradient_fade:symmetric_pad", x: "0.5"}
  ]})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation background="auto:predominant" height="300" width="300" crop="pad" />
  <Transformation effect="gradient_fade:symmetric_pad" x="0.5" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation background="auto:predominant" height="300" width="300" crop="pad" />
  <cld-transformation effect="gradient_fade:symmetric_pad" x="0.5" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation background="auto:predominant" height="300" width="300" crop="pad">
  </cl-transformation>
  <cl-transformation effect="gradient_fade:symmetric_pad" x="0.5">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Background("auto:predominant").Height(300).Width(300).Crop("pad").Chain()
  .Effect("gradient_fade:symmetric_pad").X(0.5)).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setBackground("auto:predominant").setHeight(300).setWidth(300).setCrop("pad").chain()
  .setEffect("gradient_fade:symmetric_pad").setX(0.5)).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .background("auto:predominant").height(300).width(300).crop("pad").chain()
  .effect("gradient_fade:symmetric_pad").x(0.5)).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("sample.jpg")
   resize(Resize.pad() { width(300)
 height(300)
   background(
  Background.predominant())
   })
   effect(Effect.gradientFade() {
   type(
  GradientFade.symmetricPad())
 horizontalStartPoint(0.5F) }) 
}.generate()
Pad to 300x300 with the predominant color set as the background color and gradient fade into padding

See full syntax: e_gradient_fade in the Transformation Reference.

Blending and masking layers

You can use the blending and masking layer effects to apply a variety of effects that blend or mask the base image based on the pixels in the layer image.

Blending and masking effects: e_mask, e_multiply, e_overlay, e_screen

For example, to make each pixel of the sample image brighter according to the pixel value of the overlaid cloudinary_icon_blue image:

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :transformation=>[
  {:overlay=>"cloudinary_icon_blue"},
  {:effect=>"screen", :flags=>"layer_apply"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->overlay(Overlay::source(
  Source::image("cloudinary_icon_blue"))
  ->blendMode(
  BlendMode::screen())
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("overlay"=>"cloudinary_icon_blue"),
  array("effect"=>"screen", "flags"=>"layer_apply")
  )))
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(transformation=[
  {'overlay': "cloudinary_icon_blue"},
  {'effect': "screen", 'flags': "layer_apply"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {transformation: [
  {overlay: "cloudinary_icon_blue"},
  {effect: "screen", flags: "layer_apply"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
  .effect("screen").flags("layer_apply")).imageTag("sample.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("sample.jpg").overlay(
  source(image("cloudinary_icon_blue")).blendMode("screen")
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample.jpg', {transformation: [
  {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
  {effect: "screen", flags: "layer_apply"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {transformation: [
  {overlay: new cloudinary.Layer().publicId("cloudinary_icon_blue")},
  {effect: "screen", flags: "layer_apply"}
  ]})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation overlay="cloudinary_icon_blue" />
  <Transformation effect="screen" flags="layer_apply" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation :overlay="cloudinary_icon_blue" />
  <cld-transformation effect="screen" flags="layer_apply" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation overlay="cloudinary_icon_blue">
  </cl-transformation>
  <cl-transformation effect="screen" flags="layer_apply">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new Layer().PublicId("cloudinary_icon_blue")).Chain()
  .Effect("screen").Flags("layer_apply")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setOverlay("cloudinary_icon_blue").chain()
  .setEffect("screen").setFlags("layer_apply")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .overlay(new Layer().publicId("cloudinary_icon_blue")).chain()
  .effect("screen").flags("layer_apply")).generate("sample.jpg");
Kotlin:
Copy to clipboard
// This code example is not currently available.
Image made brighter according to overlay

Borders

Add a solid border around an image with the border parameter (bo in URLs). The parameter accepts a value with a CSS-like format: width_style_color (e.g., 3px_solid_black).

An opaque color can be set as an RGB hex triplet (e.g., rgb:3e2222), a 3-digit RGB hex (e.g., rgb:777) or a named color (e.g., green).

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).

Additionally, Cloudinary's client libraries also support a # shortcut for RGB (e.g., setting color to #3e2222 which is then translated to rgb:3e2222), and when using Cloudinary's client libraries, you can optionally set the border values programmatically instead of as a single string (e.g., :border => { :width => 4, :color => 'black' }).

Note
Currently only the 'solid' border style is supported.

For example, the uploaded jpg image named sample delivered with a 5 pixel red border:

Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :border=>"5px_solid_red")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->border(Border::solid(5,Color::RED));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("border"=>"5px_solid_red"))
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(border="5px_solid_red")
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {border: "5px_solid_red"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().border("5px_solid_red")).imageTag("sample.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("sample.jpg").border(solid(5, "red"));
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample.jpg', {border: "5px_solid_red"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {border: "5px_solid_red"})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation border="5px_solid_red" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation border="5px_solid_red" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation border="5px_solid_red">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Border("5px_solid_red")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setBorder("5px_solid_red")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().border("5px_solid_red")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("sample.jpg")
   border(Border.solid(5,Color.RED)) 
}.generate()
Image delivered with 5 pixel red border

Borders are also useful for adding to overlays to clearly define the overlaying image, and also automatically adapt to any rounded corner transformations. For example, an image of lady cropped with face detection and given rounded corners with a 10 pixel grey border, and an overlay of the image of young_couple resized to a 150x150 circular thumbnail with face detection and a black 3 pixel border, added to the northeast corner:

Ruby:
Copy to clipboard
cl_image_tag("lady.jpg", :transformation=>[
  {:gravity=>"face", :crop=>"crop"},
  {:border=>"10px_solid_grey", :radius=>75},
  {:overlay=>"young_couple"},
  {:gravity=>"faces", :height=>150, :width=>150, :crop=>"thumb"},
  {:border=>"3px_solid_black", :radius=>"max"},
  {:flags=>"layer_apply", :gravity=>"north_east"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('lady.jpg'))
  ->resize(Resize::crop()
  ->gravity(
  Gravity::focusOn(
  FocusOn::face()))
  )
  ->border(Border::solid(10,Color::GREY)
  ->roundCorners(
  RoundCorners::byRadius(75))
  )
  ->overlay(Overlay::source(
  Source::image("young_couple")
  ->transformation((new Transformation())
  ->resize(Resize::thumbnail()->width(150)
->height(150)
  ->gravity(
  Gravity::focusOn(
  FocusOn::faces()))
  )
  ->border(Border::solid(3,Color::BLACK)
  ->roundCorners(
  RoundCorners::max())
  ))
  )
  ->position((new Position())
  ->gravity(
  Gravity::compass(
  Compass::northEast()))
  )
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("lady.jpg", array("transformation"=>array(
  array("gravity"=>"face", "crop"=>"crop"),
  array("border"=>"10px_solid_grey", "radius"=>75),
  array("overlay"=>"young_couple"),
  array("gravity"=>"faces", "height"=>150, "width"=>150, "crop"=>"thumb"),
  array("border"=>"3px_solid_black", "radius"=>"max"),
  array("flags"=>"layer_apply", "gravity"=>"north_east")
  )))
Python:
Copy to clipboard
CloudinaryImage("lady.jpg").image(transformation=[
  {'gravity': "face", 'crop': "crop"},
  {'border': "10px_solid_grey", 'radius': 75},
  {'overlay': "young_couple"},
  {'gravity': "faces", 'height': 150, 'width': 150, 'crop': "thumb"},
  {'border': "3px_solid_black", 'radius': "max"},
  {'flags': "layer_apply", 'gravity': "north_east"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("lady.jpg", {transformation: [
  {gravity: "face", crop: "crop"},
  {border: "10px_solid_grey", radius: 75},
  {overlay: "young_couple"},
  {gravity: "faces", height: 150, width: 150, crop: "thumb"},
  {border: "3px_solid_black", radius: "max"},
  {flags: "layer_apply", gravity: "north_east"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .gravity("face").crop("crop").chain()
  .border("10px_solid_grey").radius(75).chain()
  .overlay(new Layer().publicId("young_couple")).chain()
  .gravity("faces").height(150).width(150).crop("thumb").chain()
  .border("3px_solid_black").radius("max").chain()
  .flags("layer_apply").gravity("north_east")).imageTag("lady.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('lady.jpg', {transformation: [
  {gravity: "face", crop: "crop"},
  {border: "10px_solid_grey", radius: 75},
  {overlay: new cloudinary.Layer().publicId("young_couple")},
  {gravity: "faces", height: 150, width: 150, crop: "thumb"},
  {border: "3px_solid_black", radius: "max"},
  {flags: "layer_apply", gravity: "north_east"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("lady.jpg", {transformation: [
  {gravity: "face", crop: "crop"},
  {border: "10px_solid_grey", radius: 75},
  {overlay: new cloudinary.Layer().publicId("young_couple")},
  {gravity: "faces", height: 150, width: 150, crop: "thumb"},
  {border: "3px_solid_black", radius: "max"},
  {flags: "layer_apply", gravity: "north_east"}
  ]})
React:
Copy to clipboard
<Image publicId="lady.jpg" >
  <Transformation gravity="face" crop="crop" />
  <Transformation border="10px_solid_grey" radius="75" />
  <Transformation overlay="young_couple" />
  <Transformation gravity="faces" height="150" width="150" crop="thumb" />
  <Transformation border="3px_solid_black" radius="max" />
  <Transformation flags="layer_apply" gravity="north_east" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="lady.jpg" >
  <cld-transformation gravity="face" crop="crop" />
  <cld-transformation border="10px_solid_grey" radius="75" />
  <cld-transformation :overlay="young_couple" />
  <cld-transformation gravity="faces" height="150" width="150" crop="thumb" />
  <cld-transformation border="3px_solid_black" radius="max" />
  <cld-transformation flags="layer_apply" gravity="north_east" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="lady.jpg" >
  <cl-transformation gravity="face" crop="crop">
  </cl-transformation>
  <cl-transformation border="10px_solid_grey" radius="75">
  </cl-transformation>
  <cl-transformation overlay="young_couple">
  </cl-transformation>
  <cl-transformation gravity="faces" height="150" width="150" crop="thumb">
  </cl-transformation>
  <cl-transformation border="3px_solid_black" radius="max">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="north_east">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Gravity("face").Crop("crop").Chain()
  .Border("10px_solid_grey").Radius(75).Chain()
  .Overlay(new Layer().PublicId("young_couple")).Chain()
  .Gravity("faces").Height(150).Width(150).Crop("thumb").Chain()
  .Border("3px_solid_black").Radius("max").Chain()
  .Flags("layer_apply").Gravity("north_east")).BuildImageTag("lady.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setGravity("face").setCrop("crop").chain()
  .setBorder("10px_solid_grey").setRadius(75).chain()
  .setOverlay("young_couple").chain()
  .setGravity("faces").setHeight(150).setWidth(150).setCrop("thumb").chain()
  .setBorder("3px_solid_black").setRadius("max").chain()
  .setFlags("layer_apply").setGravity("north_east")).generate("lady.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .gravity("face").crop("crop").chain()
  .border("10px_solid_grey").radius(75).chain()
  .overlay(new Layer().publicId("young_couple")).chain()
  .gravity("faces").height(150).width(150).crop("thumb").chain()
  .border("3px_solid_black").radius("max").chain()
  .flags("layer_apply").gravity("north_east")).generate("lady.jpg");
Kotlin:
Copy to clipboard
// This code example is not currently available.
Base image with rounded corners + overlay with rounded corners

Note
When using the border parameter to set the border color of a text overlay, you can also set the color to predominant_contrast. This selects the strongest contrasting color to the predominant color while taking all pixels in the image into account. For example, l_text:Arial_30:foo,bo_3px_solid_predominant_contrast

See full syntax: bo (border) in the Transformation Reference.

Color blind effects

Cloudinary has a number of features that can help you to choose the best images as well as to transform problematic images to ones that are more accessible to color blind people. You can use Cloudinary to:

  • Simulate how an image would look to people with different color blind conditions.
  • Assist people with color blind conditions to help differentiate problematic colors.
  • Analyze images to provide color blind accessibility scores and information on which colors are the hardest to differentiate.

Simulate color blind conditions

You can simulate a number of different color blind conditions using the simulate_colorblind effect. For full syntax and supported conditions, see the e_simulate_colorblind parameter in the Transformation URL API Reference.

Simulate the way an image would appear to someone with deuteranopia (most common form of) color blindness:

Ruby:
Copy to clipboard
cl_image_tag("docs/colorblind_green_red.jpg", :effect=>"simulate_colorblind:deuteranopia")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('docs/colorblind_green_red.jpg'))
  ->effect(Effect::simulateColorBlind()
  ->condition(
  SimulateColorBlind::deuteranopia())
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("docs/colorblind_green_red.jpg", array("effect"=>"simulate_colorblind:deuteranopia"))
Python:
Copy to clipboard
CloudinaryImage("docs/colorblind_green_red.jpg").image(effect="simulate_colorblind:deuteranopia")
Node.js:
Copy to clipboard
cloudinary.image("docs/colorblind_green_red.jpg", {effect: "simulate_colorblind:deuteranopia"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("simulate_colorblind:deuteranopia")).imageTag("docs/colorblind_green_red.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("docs/colorblind_green_red.jpg").effect(
  simulateColorBlind().condition("deuteranopia")
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('docs/colorblind_green_red.jpg', {effect: "simulate_colorblind:deuteranopia"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("docs/colorblind_green_red.jpg", {effect: "simulate_colorblind:deuteranopia"})
React:
Copy to clipboard
<Image publicId="docs/colorblind_green_red.jpg" >
  <Transformation effect="simulate_colorblind:deuteranopia" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="docs/colorblind_green_red.jpg" >
  <cld-transformation effect="simulate_colorblind:deuteranopia" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="docs/colorblind_green_red.jpg" >
  <cl-transformation effect="simulate_colorblind:deuteranopia">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("simulate_colorblind:deuteranopia")).BuildImageTag("docs/colorblind_green_red.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("simulate_colorblind:deuteranopia")).generate("docs/colorblind_green_red.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("simulate_colorblind:deuteranopia")).generate("docs/colorblind_green_red.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("docs/colorblind_green_red.jpg")
   effect(Effect.simulateColorBlind() {
   condition(
  SimulateColorBlind.deuteranopia())
   }) 
}.generate()

Red and green image Original image Red and green image when simulating color blind condition Deuteranopia simulation

See full syntax: e_simulate_colorblind in the Transformation Reference.

Assist people with color blind conditions

Use the assist_colorblind effect (e_assist_colorblind in URLs) to help people with color blind conditions to differentiate between colors.

You can add stripes in different directions and thicknesses to different colors, making them easier to differentiate, for example:

Ruby:
Copy to clipboard
cl_image_tag("docs/colorblind_green_red.jpg", :effect=>"assist_colorblind:8")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('docs/colorblind_green_red.jpg'))
  ->effect(Effect::assistColorBlind()->stripesStrength(8));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("docs/colorblind_green_red.jpg", array("effect"=>"assist_colorblind:8"))
Python:
Copy to clipboard
CloudinaryImage("docs/colorblind_green_red.jpg").image(effect="assist_colorblind:8")
Node.js:
Copy to clipboard
cloudinary.image("docs/colorblind_green_red.jpg", {effect: "assist_colorblind:8"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("assist_colorblind:8")).imageTag("docs/colorblind_green_red.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("docs/colorblind_green_red.jpg").effect(
  assistColorBlind().stripesStrength(8)
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('docs/colorblind_green_red.jpg', {effect: "assist_colorblind:8"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("docs/colorblind_green_red.jpg", {effect: "assist_colorblind:8"})
React:
Copy to clipboard
<Image publicId="docs/colorblind_green_red.jpg" >
  <Transformation effect="assist_colorblind:8" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="docs/colorblind_green_red.jpg" >
  <cld-transformation effect="assist_colorblind:8" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="docs/colorblind_green_red.jpg" >
  <cl-transformation effect="assist_colorblind:8">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("assist_colorblind:8")).BuildImageTag("docs/colorblind_green_red.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("assist_colorblind:8")).generate("docs/colorblind_green_red.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("assist_colorblind:8")).generate("docs/colorblind_green_red.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("docs/colorblind_green_red.jpg")
   effect(Effect.assistColorBlind() { stripesStrength(8) }) 
}.generate()
Help a color blind user differentiate similar colors with stripes

A color blind person would see the stripes like this:

Stripe color-blind assistance with simulation

Alternatively, you can use color shifts to make colors easier to distinguish by specifying the xray assist type, for example:

Ruby:
Copy to clipboard
cl_image_tag("docs/colorblind_green_red.jpg", :effect=>"assist_colorblind:xray")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('docs/colorblind_green_red.jpg'))
  ->effect(Effect::assistColorBlind()->xray());
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("docs/colorblind_green_red.jpg", array("effect"=>"assist_colorblind:xray"))
Python:
Copy to clipboard
CloudinaryImage("docs/colorblind_green_red.jpg").image(effect="assist_colorblind:xray")
Node.js:
Copy to clipboard
cloudinary.image("docs/colorblind_green_red.jpg", {effect: "assist_colorblind:xray"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("assist_colorblind:xray")).imageTag("docs/colorblind_green_red.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("docs/colorblind_green_red.jpg").effect(
  assistColorBlind().xray()
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('docs/colorblind_green_red.jpg', {effect: "assist_colorblind:xray"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("docs/colorblind_green_red.jpg", {effect: "assist_colorblind:xray"})
React:
Copy to clipboard
<Image publicId="docs/colorblind_green_red.jpg" >
  <Transformation effect="assist_colorblind:xray" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="docs/colorblind_green_red.jpg" >
  <cld-transformation effect="assist_colorblind:xray" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="docs/colorblind_green_red.jpg" >
  <cl-transformation effect="assist_colorblind:xray">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("assist_colorblind:xray")).BuildImageTag("docs/colorblind_green_red.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("assist_colorblind:xray")).generate("docs/colorblind_green_red.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("assist_colorblind:xray")).generate("docs/colorblind_green_red.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("docs/colorblind_green_red.jpg")
   effect(Effect.assistColorBlind() { xray() }) 
}.generate()
Help a colorblind user differentiate similar colors with color shifts

See full syntax: e_assist_colorblind in the Transformation Reference.

Displacement maps

You can displace pixels in a source image based on the intensity of pixels in a displacement map image using the e_displace effect in conjunction with a displacement map image specified as an overlay. This can be useful to create interesting effects in a select area of an image or to warp the entire image to fit a needed design or texture. For example, to make an image wrap around a coffee cup or appear to be printed on a textured canvas.

The displace effect (e_displace in URLs) algorithm displaces the pixels in an image according to the color channels of the pixels in another specified image (a gradient map specified with the overlay parameter). The displace effect is added in the same component as the layer_apply flag. The red channel controls horizontal displacement, green controls vertical displacement, and the blue channel is ignored. The final displacement of each pixel in the base image is determined by a combination of the red and green color channels, together with the configured x and/or y parameters. For example, for a given x value of 20 and a pixel with a red value of 255 (highest), the corresponding base image pixel would be displaced by 20 pixels horizontally, while a red value of 25 (10%) would only displace the base image pixel by 2 pixels horizontally.

This is a standard displacement map algorithm used by popular image editing tools, so you can upload existing displacement maps found on the internet or created by your graphic artists to your account and specify them as the overlay asset, enabling you to dynamically apply the displacement effect on other images in your account or those uploaded by your end users.

Several sample use-case of this layer-based effect are shown in the sections below.

See full syntax: e_displace in the Transformation Reference.

Use case: Warp an image to fit a 3-dimensional product

Use a displacement map to warp the perspective of an overlay image for final placement as an overlay on a mug:

displacement map for image overlay

Ruby:
Copy to clipboard
cl_image_tag("sample", :use_root_path=>true, :transformation=>[
  {:overlay=>"radialize"},
  {:effect=>"displace", :flags=>"layer_apply", :x=>50, :y=>50}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
// This code example is not currently available.
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample", array("use_root_path"=>true, "transformation"=>array(
  array("overlay"=>"radialize"),
  array("effect"=>"displace", "flags"=>"layer_apply", "x"=>50, "y"=>50)
  )))
Python:
Copy to clipboard
CloudinaryImage("sample").image(use_root_path=True, transformation=[
  {'overlay': "radialize"},
  {'effect': "displace", 'flags': "layer_apply", 'x': 50, 'y': 50}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample", {use_root_path: true, transformation: [
  {overlay: "radialize"},
  {effect: "displace", flags: "layer_apply", x: 50, y: 50}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .overlay(new Layer().publicId("radialize")).chain()
  .effect("displace").flags("layer_apply").x(50).y(50)).useRootPath(true).imageTag("sample");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample', {useRootPath: true, transformation: [
  {overlay: new cloudinary.Layer().publicId("radialize")},
  {effect: "displace", flags: "layer_apply", x: 50, y: 50}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample", {use_root_path: true, transformation: [
  {overlay: new cloudinary.Layer().publicId("radialize")},
  {effect: "displace", flags: "layer_apply", x: 50, y: 50}
  ]})
React:
Copy to clipboard
<Image publicId="sample" useRootPath="true">
  <Transformation overlay="radialize" />
  <Transformation effect="displace" flags="layer_apply" x="50" y="50" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample" use-root-path="true">
  <cld-transformation :overlay="radialize" />
  <cld-transformation effect="displace" flags="layer_apply" x="50" y="50" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample" use-root-path="true">
  <cl-transformation overlay="radialize">
  </cl-transformation>
  <cl-transformation effect="displace" flags="layer_apply" x="50" y="50">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new Layer().PublicId("radialize")).Chain()
  .Effect("displace").Flags("layer_apply").X(50).Y(50)).UseRootPath(true).BuildImageTag("sample")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setUseRootPath( true).setTransformation(CLDTransformation()
  .setOverlay("radialize").chain()
  .setEffect("displace").setFlags("layer_apply").setX(50).setY(50)).generate("sample")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .overlay(new Layer().publicId("radialize")).chain()
  .effect("displace").flags("layer_apply").x(50).y(50)).useRootPath(true).generate("sample");
Kotlin:
Copy to clipboard
// This code example is not currently available.

Using this overlay transformation for placement on a mug:

Zoom displacement map

Ruby:
Copy to clipboard
cl_image_tag("left_mug", :use_root_path=>true, :transformation=>[
  {:width=>500, :crop=>"scale"},
  {:overlay=>"sample.png"},
  {:height=>250, :width=>250, :crop=>"pad"},
  {:overlay=>"radialize"},
  {:effect=>"displace", :flags=>"layer_apply", :y=>-8},
  {:background=>"transparent", :flags=>"layer_apply", :x=>10}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
// This code example is not currently available.
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("left_mug", array("use_root_path"=>true, "transformation"=>array(
  array("width"=>500, "crop"=>"scale"),
  array("overlay"=>"sample.png"),
  array("height"=>250, "width"=>250, "crop"=>"pad"),
  array("overlay"=>"radialize"),
  array("effect"=>"displace", "flags"=>"layer_apply", "y"=>-8),
  array("background"=>"transparent", "flags"=>"layer_apply", "x"=>10)
  )))
Python:
Copy to clipboard
CloudinaryImage("left_mug").image(use_root_path=True, transformation=[
  {'width': 500, 'crop': "scale"},
  {'overlay': "sample.png"},
  {'height': 250, 'width': 250, 'crop': "pad"},
  {'overlay': "radialize"},
  {'effect': "displace", 'flags': "layer_apply", 'y': -8},
  {'background': "transparent", 'flags': "layer_apply", 'x': 10}
  ])
Node.js:
Copy to clipboard
cloudinary.image("left_mug", {use_root_path: true, transformation: [
  {width: 500, crop: "scale"},
  {overlay: "sample.png"},
  {height: 250, width: 250, crop: "pad"},
  {overlay: "radialize"},
  {effect: "displace", flags: "layer_apply", y: -8},
  {background: "transparent", flags: "layer_apply", x: 10}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new Layer().publicId("sample.png")).chain()
  .height(250).width(250).crop("pad").chain()
  .overlay(new Layer().publicId("radialize")).chain()
  .effect("displace").flags("layer_apply").y(-8).chain()
  .background("transparent").flags("layer_apply").x(10)).useRootPath(true).imageTag("left_mug");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('left_mug', {useRootPath: true, transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("sample.png")},
  {height: 250, width: 250, crop: "pad"},
  {overlay: new cloudinary.Layer().publicId("radialize")},
  {effect: "displace", flags: "layer_apply", y: -8},
  {background: "transparent", flags: "layer_apply", x: 10}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("left_mug", {use_root_path: true, transformation: [
  {width: 500, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("sample.png")},
  {height: 250, width: 250, crop: "pad"},
  {overlay: new cloudinary.Layer().publicId("radialize")},
  {effect: "displace", flags: "layer_apply", y: -8},
  {background: "transparent", flags: "layer_apply", x: 10}
  ]})
React:
Copy to clipboard
<Image publicId="left_mug" useRootPath="true">
  <Transformation width="500" crop="scale" />
  <Transformation overlay="sample.png" />
  <Transformation height="250" width="250" crop="pad" />
  <Transformation overlay="radialize" />
  <Transformation effect="displace" flags="layer_apply" y="-8" />
  <Transformation background="transparent" flags="layer_apply" x="10" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="left_mug" use-root-path="true">
  <cld-transformation width="500" crop="scale" />
  <cld-transformation :overlay="sample.png" />
  <cld-transformation height="250" width="250" crop="pad" />
  <cld-transformation :overlay="radialize" />
  <cld-transformation effect="displace" flags="layer_apply" y="-8" />
  <cld-transformation background="transparent" flags="layer_apply" x="10" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="left_mug" use-root-path="true">
  <cl-transformation width="500" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="sample.png">
  </cl-transformation>
  <cl-transformation height="250" width="250" crop="pad">
  </cl-transformation>
  <cl-transformation overlay="radialize">
  </cl-transformation>
  <cl-transformation effect="displace" flags="layer_apply" y="-8">
  </cl-transformation>
  <cl-transformation background="transparent" flags="layer_apply" x="10">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Crop("scale").Chain()
  .Overlay(new Layer().PublicId("sample.png")).Chain()
  .Height(250).Width(250).Crop("pad").Chain()
  .Overlay(new Layer().PublicId("radialize")).Chain()
  .Effect("displace").Flags("layer_apply").Y(-8).Chain()
  .Background("transparent").Flags("layer_apply").X(10)).UseRootPath(true).BuildImageTag("left_mug")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setUseRootPath( true).setTransformation(CLDTransformation()
  .setWidth(500).setCrop("scale").chain()
  .setOverlay("sample.png").chain()
  .setHeight(250).setWidth(250).setCrop("pad").chain()
  .setOverlay("radialize").chain()
  .setEffect("displace").setFlags("layer_apply").setY(-8).chain()
  .setBackground("transparent").setFlags("layer_apply").setX(10)).generate("left_mug")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(500).crop("scale").chain()
  .overlay(new Layer().publicId("sample.png")).chain()
  .height(250).width(250).crop("pad").chain()
  .overlay(new Layer().publicId("radialize")).chain()
  .effect("displace").flags("layer_apply").y(-8).chain()
  .background("transparent").flags("layer_apply").x(10)).useRootPath(true).generate("left_mug");
Kotlin:
Copy to clipboard
// This code example is not currently available.

Use case: Create a zoom effect

To displace the sample image by using a displacement map, creating a zoom effect:

displacement map for a zoom effect
Ruby:
Copy to clipboard
cl_image_tag("sample", :use_root_path=>true, :transformation=>[
  {:overlay=>"docs:zoom_map"},
  {:effect=>"displace", :flags=>"layer_apply", :x=>50, :y=>50}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
// This code example is not currently available.
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample", array("use_root_path"=>true, "transformation"=>array(
  array("overlay"=>"docs:zoom_map"),
  array("effect"=>"displace", "flags"=>"layer_apply", "x"=>50, "y"=>50)
  )))
Python:
Copy to clipboard
CloudinaryImage("sample").image(use_root_path=True, transformation=[
  {'overlay': "docs:zoom_map"},
  {'effect': "displace", 'flags': "layer_apply", 'x': 50, 'y': 50}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample", {use_root_path: true, transformation: [
  {overlay: "docs:zoom_map"},
  {effect: "displace", flags: "layer_apply", x: 50, y: 50}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .overlay(new Layer().publicId("docs:zoom_map")).chain()
  .effect("displace").flags("layer_apply").x(50).y(50)).useRootPath(true).imageTag("sample");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample', {useRootPath: true, transformation: [
  {overlay: new cloudinary.Layer().publicId("docs:zoom_map")},
  {effect: "displace", flags: "layer_apply", x: 50, y: 50}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample", {use_root_path: true, transformation: [
  {overlay: new cloudinary.Layer().publicId("docs:zoom_map")},
  {effect: "displace", flags: "layer_apply", x: 50, y: 50}
  ]})
React:
Copy to clipboard
<Image publicId="sample" useRootPath="true">
  <Transformation overlay="docs:zoom_map" />
  <Transformation effect="displace" flags="layer_apply" x="50" y="50" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample" use-root-path="true">
  <cld-transformation :overlay="docs:zoom_map" />
  <cld-transformation effect="displace" flags="layer_apply" x="50" y="50" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample" use-root-path="true">
  <cl-transformation overlay="docs:zoom_map">
  </cl-transformation>
  <cl-transformation effect="displace" flags="layer_apply" x="50" y="50">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Overlay(new Layer().PublicId("docs:zoom_map")).Chain()
  .Effect("displace").Flags("layer_apply").X(50).Y(50)).UseRootPath(true).BuildImageTag("sample")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setUseRootPath( true).setTransformation(CLDTransformation()
  .setOverlay("docs:zoom_map").chain()
  .setEffect("displace").setFlags("layer_apply").setX(50).setY(50)).generate("sample")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .overlay(new Layer().publicId("docs:zoom_map")).chain()
  .effect("displace").flags("layer_apply").x(50).y(50)).useRootPath(true).generate("sample");
Kotlin:
Copy to clipboard
// This code example is not currently available.

You could take this a step further by applying this displacement along with another overlay component that adds a magnifying glass. In this example, the same displacement map as above is used on a different base image and offset to a different location.

Ruby:
Copy to clipboard
cl_image_tag("woman.jpg", :use_root_path=>true, :transformation=>[
  {:height=>500, :width=>500, :crop=>"fill"},
  {:overlay=>"woman"},
  {:width=>500, :height=>500, :crop=>"fill"},
  {:height=>200, :width=>200, :x=>20, :y=>20, :crop=>"crop"},
  {:overlay=>"docs:zoom_map"},
  {:height=>200, :width=>200, :crop=>"fill"},
  {:effect=>"displace", :flags=>"layer_apply", :x=>20, :y=>20},
  {:flags=>"layer_apply", :gravity=>"north_west", :x=>20, :y=>20},
  {:overlay=>"mag-glass.png"},
  {:flags=>["layer_apply", "no_overflow"], :gravity=>"north_west", :height=>215, :width=>330, :x=>38, :y=>38, :crop=>"scale"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
// This code example is not currently available.
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("woman.jpg", array("use_root_path"=>true, "transformation"=>array(
  array("height"=>500, "width"=>500, "crop"=>"fill"),
  array("overlay"=>"woman"),
  array("width"=>500, "height"=>500, "crop"=>"fill"),
  array("height"=>200, "width"=>200, "x"=>20, "y"=>20, "crop"=>"crop"),
  array("overlay"=>"docs:zoom_map"),
  array("height"=>200, "width"=>200, "crop"=>"fill"),
  array("effect"=>"displace", "flags"=>"layer_apply", "x"=>20, "y"=>20),
  array("flags"=>"layer_apply", "gravity"=>"north_west", "x"=>20, "y"=>20),
  array("overlay"=>"mag-glass.png"),
  array("flags"=>array("layer_apply", "no_overflow"), "gravity"=>"north_west", "height"=>215, "width"=>330, "x"=>38, "y"=>38, "crop"=>"scale")
  )))
Python:
Copy to clipboard
CloudinaryImage("woman.jpg").image(use_root_path=True, transformation=[
  {'height': 500, 'width': 500, 'crop': "fill"},
  {'overlay': "woman"},
  {'width': 500, 'height': 500, 'crop': "fill"},
  {'height': 200, 'width': 200, 'x': 20, 'y': 20, 'crop': "crop"},
  {'overlay': "docs:zoom_map"},
  {'height': 200, 'width': 200, 'crop': "fill"},
  {'effect': "displace", 'flags': "layer_apply", 'x': 20, 'y': 20},
  {'flags': "layer_apply", 'gravity': "north_west", 'x': 20, 'y': 20},
  {'overlay': "mag-glass.png"},
  {'flags': ["layer_apply", "no_overflow"], 'gravity': "north_west", 'height': 215, 'width': 330, 'x': 38, 'y': 38, 'crop': "scale"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("woman.jpg", {use_root_path: true, transformation: [
  {height: 500, width: 500, crop: "fill"},
  {overlay: "woman"},
  {width: 500, height: 500, crop: "fill"},
  {height: 200, width: 200, x: 20, y: 20, crop: "crop"},
  {overlay: "docs:zoom_map"},
  {height: 200, width: 200, crop: "fill"},
  {effect: "displace", flags: "layer_apply", x: 20, y: 20},
  {flags: "layer_apply", gravity: "north_west", x: 20, y: 20},
  {overlay: "mag-glass.png"},
  {flags: ["layer_apply", "no_overflow"], gravity: "north_west", height: 215, width: 330, x: 38, y: 38, crop: "scale"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .height(500).width(500).crop("fill").chain()
  .overlay(new Layer().publicId("woman")).chain()
  .width(500).height(500).crop("fill").chain()
  .height(200).width(200).x(20).y(20).crop("crop").chain()
  .overlay(new Layer().publicId("docs:zoom_map")).chain()
  .height(200).width(200).crop("fill").chain()
  .effect("displace").flags("layer_apply").x(20).y(20).chain()
  .flags("layer_apply").gravity("north_west").x(20).y(20).chain()
  .overlay(new Layer().publicId("mag-glass.png")).chain()
  .flags("layer_apply", "no_overflow").gravity("north_west").height(215).width(330).x(38).y(38).crop("scale")).useRootPath(true).imageTag("woman.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('woman.jpg', {useRootPath: true, transformation: [
  {height: 500, width: 500, crop: "fill"},
  {overlay: new cloudinary.Layer().publicId("woman")},
  {width: 500, height: 500, crop: "fill"},
  {height: 200, width: 200, x: 20, y: 20, crop: "crop"},
  {overlay: new cloudinary.Layer().publicId("docs:zoom_map")},
  {height: 200, width: 200, crop: "fill"},
  {effect: "displace", flags: "layer_apply", x: 20, y: 20},
  {flags: "layer_apply", gravity: "north_west", x: 20, y: 20},
  {overlay: new cloudinary.Layer().publicId("mag-glass.png")},
  {flags: ["layer_apply", "no_overflow"], gravity: "north_west", height: 215, width: 330, x: 38, y: 38, crop: "scale"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("woman.jpg", {use_root_path: true, transformation: [
  {height: 500, width: 500, crop: "fill"},
  {overlay: new cloudinary.Layer().publicId("woman")},
  {width: 500, height: 500, crop: "fill"},
  {height: 200, width: 200, x: 20, y: 20, crop: "crop"},
  {overlay: new cloudinary.Layer().publicId("docs:zoom_map")},
  {height: 200, width: 200, crop: "fill"},
  {effect: "displace", flags: "layer_apply", x: 20, y: 20},
  {flags: "layer_apply", gravity: "north_west", x: 20, y: 20},
  {overlay: new cloudinary.Layer().publicId("mag-glass.png")},
  {flags: ["layer_apply", "no_overflow"], gravity: "north_west", height: 215, width: 330, x: 38, y: 38, crop: "scale"}
  ]})
React:
Copy to clipboard
<Image publicId="woman.jpg" useRootPath="true">
  <Transformation height="500" width="500" crop="fill" />
  <Transformation overlay="woman" />
  <Transformation width="500" height="500" crop="fill" />
  <Transformation height="200" width="200" x="20" y="20" crop="crop" />
  <Transformation overlay="docs:zoom_map" />
  <Transformation height="200" width="200" crop="fill" />
  <Transformation effect="displace" flags="layer_apply" x="20" y="20" />
  <Transformation flags="layer_apply" gravity="north_west" x="20" y="20" />
  <Transformation overlay="mag-glass.png" />
  <Transformation flags={["layer_apply", "no_overflow"]} gravity="north_west" height="215" width="330" x="38" y="38" crop="scale" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="woman.jpg" use-root-path="true">
  <cld-transformation height="500" width="500" crop="fill" />
  <cld-transformation :overlay="woman" />
  <cld-transformation width="500" height="500" crop="fill" />
  <cld-transformation height="200" width="200" x="20" y="20" crop="crop" />
  <cld-transformation :overlay="docs:zoom_map" />
  <cld-transformation height="200" width="200" crop="fill" />
  <cld-transformation effect="displace" flags="layer_apply" x="20" y="20" />
  <cld-transformation flags="layer_apply" gravity="north_west" x="20" y="20" />
  <cld-transformation :overlay="mag-glass.png" />
  <cld-transformation flags={["layer_apply", "no_overflow"]} gravity="north_west" height="215" width="330" x="38" y="38" crop="scale" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="woman.jpg" use-root-path="true">
  <cl-transformation height="500" width="500" crop="fill">
  </cl-transformation>
  <cl-transformation overlay="woman">
  </cl-transformation>
  <cl-transformation width="500" height="500" crop="fill">
  </cl-transformation>
  <cl-transformation height="200" width="200" x="20" y="20" crop="crop">
  </cl-transformation>
  <cl-transformation overlay="docs:zoom_map">
  </cl-transformation>
  <cl-transformation height="200" width="200" crop="fill">
  </cl-transformation>
  <cl-transformation effect="displace" flags="layer_apply" x="20" y="20">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="north_west" x="20" y="20">
  </cl-transformation>
  <cl-transformation overlay="mag-glass.png">
  </cl-transformation>
  <cl-transformation flags={{["layer_apply", "no_overflow"]}} gravity="north_west" height="215" width="330" x="38" y="38" crop="scale">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Height(500).Width(500).Crop("fill").Chain()
  .Overlay(new Layer().PublicId("woman")).Chain()
  .Width(500).Height(500).Crop("fill").Chain()
  .Height(200).Width(200).X(20).Y(20).Crop("crop").Chain()
  .Overlay(new Layer().PublicId("docs:zoom_map")).Chain()
  .Height(200).Width(200).Crop("fill").Chain()
  .Effect("displace").Flags("layer_apply").X(20).Y(20).Chain()
  .Flags("layer_apply").Gravity("north_west").X(20).Y(20).Chain()
  .Overlay(new Layer().PublicId("mag-glass.png")).Chain()
  .Flags("layer_apply", "no_overflow").Gravity("north_west").Height(215).Width(330).X(38).Y(38).Crop("scale")).UseRootPath(true).BuildImageTag("woman.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setUseRootPath( true).setTransformation(CLDTransformation()
  .setHeight(500).setWidth(500).setCrop("fill").chain()
  .setOverlay("woman").chain()
  .setWidth(500).setHeight(500).setCrop("fill").chain()
  .setHeight(200).setWidth(200).setX(20).setY(20).setCrop("crop").chain()
  .setOverlay("docs:zoom_map").chain()
  .setHeight(200).setWidth(200).setCrop("fill").chain()
  .setEffect("displace").setFlags("layer_apply").setX(20).setY(20).chain()
  .setFlags("layer_apply").setGravity("north_west").setX(20).setY(20).chain()
  .setOverlay("mag-glass.png").chain()
  .setFlags("layer_apply", "no_overflow").setGravity("north_west").setHeight(215).setWidth(330).setX(38).setY(38).setCrop("scale")).generate("woman.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .height(500).width(500).crop("fill").chain()
  .overlay(new Layer().publicId("woman")).chain()
  .width(500).height(500).crop("fill").chain()
  .height(200).width(200).x(20).y(20).crop("crop").chain()
  .overlay(new Layer().publicId("docs:zoom_map")).chain()
  .height(200).width(200).crop("fill").chain()
  .effect("displace").flags("layer_apply").x(20).y(20).chain()
  .flags("layer_apply").gravity("north_west").x(20).y(20).chain()
  .overlay(new Layer().publicId("mag-glass.png")).chain()
  .flags("layer_apply", "no_overflow").gravity("north_west").height(215).width(330).x(38).y(38).crop("scale")).useRootPath(true).generate("woman.jpg");
Kotlin:
Copy to clipboard
// This code example is not currently available.
zoomed in image

Use case: Apply a texture to your image

displacement map for a zoom effect
Ruby:
Copy to clipboard
cl_image_tag("docs/autumn_woods.jpg", :transformation=>[
  {:width=>600, :crop=>"scale"},
  {:overlay=>"docs:old-canvas-texture"},
  {:effect=>"displace", :flags=>"layer_apply", :x=>25, :y=>25},
  {:width=>585, :height=>320, :crop=>"crop"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
// This code example is not currently available.
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("docs/autumn_woods.jpg", array("transformation"=>array(
  array("width"=>600, "crop"=>"scale"),
  array("overlay"=>"docs:old-canvas-texture"),
  array("effect"=>"displace", "flags"=>"layer_apply", "x"=>25, "y"=>25),
  array("width"=>585, "height"=>320, "crop"=>"crop")
  )))
Python:
Copy to clipboard
CloudinaryImage("docs/autumn_woods.jpg").image(transformation=[
  {'width': 600, 'crop': "scale"},
  {'overlay': "docs:old-canvas-texture"},
  {'effect': "displace", 'flags': "layer_apply", 'x': 25, 'y': 25},
  {'width': 585, 'height': 320, 'crop': "crop"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("docs/autumn_woods.jpg", {transformation: [
  {width: 600, crop: "scale"},
  {overlay: "docs:old-canvas-texture"},
  {effect: "displace", flags: "layer_apply", x: 25, y: 25},
  {width: 585, height: 320, crop: "crop"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(600).crop("scale").chain()
  .overlay(new Layer().publicId("docs:old-canvas-texture")).chain()
  .effect("displace").flags("layer_apply").x(25).y(25).chain()
  .width(585).height(320).crop("crop")).imageTag("docs/autumn_woods.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('docs/autumn_woods.jpg', {transformation: [
  {width: 600, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("docs:old-canvas-texture")},
  {effect: "displace", flags: "layer_apply", x: 25, y: 25},
  {width: 585, height: 320, crop: "crop"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("docs/autumn_woods.jpg", {transformation: [
  {width: 600, crop: "scale"},
  {overlay: new cloudinary.Layer().publicId("docs:old-canvas-texture")},
  {effect: "displace", flags: "layer_apply", x: 25, y: 25},
  {width: 585, height: 320, crop: "crop"}
  ]})
React:
Copy to clipboard
<Image publicId="docs/autumn_woods.jpg" >
  <Transformation width="600" crop="scale" />
  <Transformation overlay="docs:old-canvas-texture" />
  <Transformation effect="displace" flags="layer_apply" x="25" y="25" />
  <Transformation width="585" height="320" crop="crop" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="docs/autumn_woods.jpg" >
  <cld-transformation width="600" crop="scale" />
  <cld-transformation :overlay="docs:old-canvas-texture" />
  <cld-transformation effect="displace" flags="layer_apply" x="25" y="25" />
  <cld-transformation width="585" height="320" crop="crop" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="docs/autumn_woods.jpg" >
  <cl-transformation width="600" crop="scale">
  </cl-transformation>
  <cl-transformation overlay="docs:old-canvas-texture">
  </cl-transformation>
  <cl-transformation effect="displace" flags="layer_apply" x="25" y="25">
  </cl-transformation>
  <cl-transformation width="585" height="320" crop="crop">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(600).Crop("scale").Chain()
  .Overlay(new Layer().PublicId("docs:old-canvas-texture")).Chain()
  .Effect("displace").Flags("layer_apply").X(25).Y(25).Chain()
  .Width(585).Height(320).Crop("crop")).BuildImageTag("docs/autumn_woods.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(600).setCrop("scale").chain()
  .setOverlay("docs:old-canvas-texture").chain()
  .setEffect("displace").setFlags("layer_apply").setX(25).setY(25).chain()
  .setWidth(585).setHeight(320).setCrop("crop")).generate("docs/autumn_woods.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(600).crop("scale").chain()
  .overlay(new Layer().publicId("docs:old-canvas-texture")).chain()
  .effect("displace").flags("layer_apply").x(25).y(25).chain()
  .width(585).height(320).crop("crop")).generate("docs/autumn_woods.jpg");
Kotlin:
Copy to clipboard
// This code example is not currently available.

Interactive texture demo

For more details on displacement mapping with the displace effect, see the article on Displacement Maps for Easy Image Transformations with Cloudinary. The article includes a variety of examples, as well as an interactive demo.

Distort

Using the distort effect, you can change the shape of an image, distorting its dimensions and the image itself. It works in one of two modes: you can either change the positioning of each of the corners, or you can warp the image into an arc.

To change the positioning of each of the corners, it is helpful to have in mind a picture like the one below. The solid rectangle shows the coordinates of the corners of the original image. The intended result of the distortion is represented by the dashed shape. The new corner coordinates are specified in the distort effect as x,y pairs, clockwise from top-left. For example:

Distortion coordinates
Ruby:
Copy to clipboard
cl_image_tag("sample.jpg", :transformation=>[
  {:width=>300, :crop=>"scale"},
  {:effect=>"distort:40:25:280:60:260:155:35:165"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('sample.jpg'))
  ->resize(Resize::scale()->width(300))
  ->reshape(Reshape::distort([40, 25, 280, 60, 260, 155, 35, 165]));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("width"=>300, "crop"=>"scale"),
  array("effect"=>"distort:40:25:280:60:260:155:35:165")
  )))
Python:
Copy to clipboard
CloudinaryImage("sample.jpg").image(transformation=[
  {'width': 300, 'crop': "scale"},
  {'effect': "distort:40:25:280:60:260:155:35:165"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("sample.jpg", {transformation: [
  {width: 300, crop: "scale"},
  {effect: "distort:40:25:280:60:260:155:35:165"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(300).crop("scale").chain()
  .effect("distort:40:25:280:60:260:155:35:165")).imageTag("sample.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("sample.jpg")
  .resize(scale().width(300))
  .reshape(distort([40, 25, 280, 60, 260, 155, 35, 165]));
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('sample.jpg', {transformation: [
  {width: 300, crop: "scale"},
  {effect: "distort:40:25:280:60:260:155:35:165"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("sample.jpg", {transformation: [
  {width: 300, crop: "scale"},
  {effect: "distort:40:25:280:60:260:155:35:165"}
  ]})
React:
Copy to clipboard
<Image publicId="sample.jpg" >
  <Transformation width="300" crop="scale" />
  <Transformation effect="distort:40:25:280:60:260:155:35:165" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="sample.jpg" >
  <cld-transformation width="300" crop="scale" />
  <cld-transformation effect="distort:40:25:280:60:260:155:35:165" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="sample.jpg" >
  <cl-transformation width="300" crop="scale">
  </cl-transformation>
  <cl-transformation effect="distort:40:25:280:60:260:155:35:165">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(300).Crop("scale").Chain()
  .Effect("distort:40:25:280:60:260:155:35:165")).BuildImageTag("sample.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(300).setCrop("scale").chain()
  .setEffect("distort:40:25:280:60:260:155:35:165")).generate("sample.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(300).crop("scale").chain()
  .effect("distort:40:25:280:60:260:155:35:165")).generate("sample.jpg");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("sample.jpg")
   resize(Resize.scale() { width(300) })
   reshape(Reshape.distort(listOf(40, 25, 280, 60, 260, 155, 35, 165))) 
}.generate()
Image distorted to new shape

For more details on perspective warping with the distort effect, see the article on How to dynamically distort images to fit your graphic design.

To curve an image, you can specify arc and the number of degrees in the distort effect, instead of the corner coordinates. If you specify a positive value for the number of degrees, the image is curved upwards, like a frown. Negative values curve the image downwards, like a smile.

You can distort text in the same way as images, for example, to add curved text to the frisbee image (e_distort:arc:-120):

Ruby:
Copy to clipboard
cl_image_tag("frisbee.jpg", :transformation=>[
  {:color=>"white", :overlay=>{:font_family=>"impact", :font_size=>150, :text=>"Your%20Brand%20Name%20or%20Logo%20Here"}},
  {:opacity=>60},
  {:effect=>"distort:arc:-120.0"},
  {:flags=>"layer_apply", :gravity=>"south", :y=>840}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('frisbee.jpg'))
  ->overlay(Overlay::source(
  Source::text("Your Brand Name or Logo Here",(new TextStyle("impact",150)))
  ->textColor(Color::WHITE)
  ->transformation((new Transformation())
  ->adjust(Adjust::opacity(60))
  ->reshape(Reshape::distortArc(-120.0)))
  )
  ->position((new Position())
  ->gravity(
  Gravity::compass(
  Compass::south()))
->offsetY(840))
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("frisbee.jpg", array("transformation"=>array(
  array("color"=>"white", "overlay"=>array("font_family"=>"impact", "font_size"=>150, "text"=>"Your%20Brand%20Name%20or%20Logo%20Here")),
  array("opacity"=>60),
  array("effect"=>"distort:arc:-120.0"),
  array("flags"=>"layer_apply", "gravity"=>"south", "y"=>840)
  )))
Python:
Copy to clipboard
CloudinaryImage("frisbee.jpg").image(transformation=[
  {'color': "white", 'overlay': {'font_family': "impact", 'font_size': 150, 'text': "Your%20Brand%20Name%20or%20Logo%20Here"}},
  {'opacity': 60},
  {'effect': "distort:arc:-120.0"},
  {'flags': "layer_apply", 'gravity': "south", 'y': 840}
  ])
Node.js:
Copy to clipboard
cloudinary.image("frisbee.jpg", {transformation: [
  {color: "white", overlay: {font_family: "impact", font_size: 150, text: "Your%20Brand%20Name%20or%20Logo%20Here"}},
  {opacity: 60},
  {effect: "distort:arc:-120.0"},
  {flags: "layer_apply", gravity: "south", y: 840}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .color("white").overlay(new TextLayer().fontFamily("impact").fontSize(150).text("Your%20Brand%20Name%20or%20Logo%20Here")).chain()
  .opacity(60).chain()
  .effect("distort:arc:-120.0").chain()
  .flags("layer_apply").gravity("south").y(840)).imageTag("frisbee.jpg");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('frisbee.jpg', {transformation: [
  {color: "white", overlay: new cloudinary.TextLayer().fontFamily("impact").fontSize(150).text("Your%20Brand%20Name%20or%20Logo%20Here")},
  {opacity: 60},
  {effect: "distort:arc:-120.0"},
  {flags: "layer_apply", gravity: "south", y: 840}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("frisbee.jpg", {transformation: [
  {color: "white", overlay: new cloudinary.TextLayer().fontFamily("impact").fontSize(150).text("Your%20Brand%20Name%20or%20Logo%20Here")},
  {opacity: 60},
  {effect: "distort:arc:-120.0"},
  {flags: "layer_apply", gravity: "south", y: 840}
  ]})
React:
Copy to clipboard
<Image publicId="frisbee.jpg" >
  <Transformation color="white" overlay={{fontFamily: "impact", fontSize: 150, text: "Your%20Brand%20Name%20or%20Logo%20Here"}} />
  <Transformation opacity="60" />
  <Transformation effect="distort:arc:-120.0" />
  <Transformation flags="layer_apply" gravity="south" y="840" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="frisbee.jpg" >
  <cld-transformation color="white" :overlay="{fontFamily: 'impact', fontSize: 150, text: 'Your%20Brand%20Name%20or%20Logo%20Here'}" />
  <cld-transformation opacity="60" />
  <cld-transformation effect="distort:arc:-120.0" />
  <cld-transformation flags="layer_apply" gravity="south" y="840" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="frisbee.jpg" >
  <cl-transformation color="white" overlay="text:impact_150:Your%20Brand%20Name%20or%20Logo%20Here">
  </cl-transformation>
  <cl-transformation opacity="60">
  </cl-transformation>
  <cl-transformation effect="distort:arc:-120.0">
  </cl-transformation>
  <cl-transformation flags="layer_apply" gravity="south" y="840">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Color("white").Overlay(new TextLayer().FontFamily("impact").FontSize(150).Text("Your%20Brand%20Name%20or%20Logo%20Here")).Chain()
  .Opacity(60).Chain()
  .Effect("distort:arc:-120.0").Chain()
  .Flags("layer_apply").Gravity("south").Y(840)).BuildImageTag("frisbee.jpg")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setColor("white").setOverlay("text:impact_150:Your%20Brand%20Name%20or%20Logo%20Here").chain()
  .setOpacity(60).chain()
  .setEffect("distort:arc:-120.0").chain()
  .setFlags("layer_apply").setGravity("south").setY(840)).generate("frisbee.jpg")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .color("white").overlay(new TextLayer().fontFamily("impact").fontSize(150).text("Your%20Brand%20Name%20or%20Logo%20Here")).chain()
  .opacity(60).chain()
  .effect("distort:arc:-120.0").chain()
  .flags("layer_apply").gravity("south").y(840)).generate("frisbee.jpg");
Kotlin:
Copy to clipboard
// This code example is not currently available.
Curved text distortion

See full syntax: e_distort in the Transformation Reference.

Outline

The outline effect (e_outline in URLs) enables you to add an outline to your transparent images. The parameter can also be passed additional values as follows:

Copy to clipboard
outline:[mode]:[width]:[blur]
  • mode - how to apply the outline effect which can be one of the following values: inner, inner_fill, outer, fill. Default value: inner and outer.
  • width - the first integer supplied applies to the thickness of the outline in pixels. Default value: 5. Range: 1 - 100
  • blur - the second integer supplied applies to the level of blur of the outline. Default value: 0. Range: 0 - 2000
Original Original e_outline e_outline e_outline:inner e_outline:inner e_outline:inner_fill e_outline:inner_fill e_outline:outer e_outline:outer e_outline:fill e_outline:fill

Use the color parameter (co in URLs) to define a new color for the outline (the default is black). The color can be specified as an RGB hex triplet (e.g., rgb:3e2222), a 3-digit RGB hex (e.g., rgb:777) or a named color (e.g., green). For example, to add an orange outline:

Ruby:
Copy to clipboard
cl_image_tag("balloon.png", :transformation=>[
  {:height=>200, :crop=>"scale"},
  {:color=>"orange", :effect=>"outline:15:200"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('balloon.png'))
  ->resize(Resize::scale()->height(200))
  ->effect(Effect::outline()->width(15)
->blurLevel(200)
  ->color(Color::ORANGE)
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("balloon.png", array("transformation"=>array(
  array("height"=>200, "crop"=>"scale"),
  array("color"=>"orange", "effect"=>"outline:15:200")
  )))
Python:
Copy to clipboard
CloudinaryImage("balloon.png").image(transformation=[
  {'height': 200, 'crop': "scale"},
  {'color': "orange", 'effect': "outline:15:200"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("balloon.png", {transformation: [
  {height: 200, crop: "scale"},
  {color: "orange", effect: "outline:15:200"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .height(200).crop("scale").chain()
  .color("orange").effect("outline:15:200")).imageTag("balloon.png");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("balloon.png").resize(scale().height(200)).effect(
  outline()
    .width(15)
    .blurLevel(200)
    .color("orange")
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('balloon.png', {transformation: [
  {height: 200, crop: "scale"},
  {color: "orange", effect: "outline:15:200"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("balloon.png", {transformation: [
  {height: 200, crop: "scale"},
  {color: "orange", effect: "outline:15:200"}
  ]})
React:
Copy to clipboard
<Image publicId="balloon.png" >
  <Transformation height="200" crop="scale" />
  <Transformation color="orange" effect="outline:15:200" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="balloon.png" >
  <cld-transformation height="200" crop="scale" />
  <cld-transformation color="orange" effect="outline:15:200" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="balloon.png" >
  <cl-transformation height="200" crop="scale">
  </cl-transformation>
  <cl-transformation color="orange" effect="outline:15:200">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Height(200).Crop("scale").Chain()
  .Color("orange").Effect("outline:15:200")).BuildImageTag("balloon.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setHeight(200).setCrop("scale").chain()
  .setColor("orange").setEffect("outline:15:200")).generate("balloon.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .height(200).crop("scale").chain()
  .color("orange").effect("outline:15:200")).generate("balloon.png");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("balloon.png")
   resize(Resize.scale() { height(200) })
   effect(Effect.outline() { width(15)
 blurLevel(200)
   color(Color.ORANGE)
   }) 
}.generate()
multiple outlines

You can also add a multi-colored outline by creating successive outline effect components. For example:

Ruby:
Copy to clipboard
cl_image_tag("shoes.png", :transformation=>[
  {:width=>200, :crop=>"scale"},
  {:color=>"red", :effect=>"outline:20:200"},
  {:color=>"orange", :effect=>"outline:15:200"},
  {:color=>"yellow", :effect=>"outline:10:200"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('shoes.png'))
  ->resize(Resize::scale()->width(200))
  ->effect(Effect::outline()->width(20)
->blurLevel(200)
  ->color(Color::RED)
  )
  ->effect(Effect::outline()->width(15)
->blurLevel(200)
  ->color(Color::ORANGE)
  )
  ->effect(Effect::outline()->width(10)
->blurLevel(200)
  ->color(Color::YELLOW)
  );
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("shoes.png", array("transformation"=>array(
  array("width"=>200, "crop"=>"scale"),
  array("color"=>"red", "effect"=>"outline:20:200"),
  array("color"=>"orange", "effect"=>"outline:15:200"),
  array("color"=>"yellow", "effect"=>"outline:10:200")
  )))
Python:
Copy to clipboard
CloudinaryImage("shoes.png").image(transformation=[
  {'width': 200, 'crop': "scale"},
  {'color': "red", 'effect': "outline:20:200"},
  {'color': "orange", 'effect': "outline:15:200"},
  {'color': "yellow", 'effect': "outline:10:200"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("shoes.png", {transformation: [
  {width: 200, crop: "scale"},
  {color: "red", effect: "outline:20:200"},
  {color: "orange", effect: "outline:15:200"},
  {color: "yellow", effect: "outline:10:200"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .width(200).crop("scale").chain()
  .color("red").effect("outline:20:200").chain()
  .color("orange").effect("outline:15:200").chain()
  .color("yellow").effect("outline:10:200")).imageTag("shoes.png");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("shoes.png")
  .resize(scale().width(200))
  .effect(
    outline()
      .width(20)
      .blurLevel(200)
      .color("red")
  )
  .effect(
    outline()
      .width(15)
      .blurLevel(200)
      .color("orange")
  )
  .effect(
    outline()
      .width(10)
      .blurLevel(200)
      .color("yellow")
  );
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('shoes.png', {transformation: [
  {width: 200, crop: "scale"},
  {color: "red", effect: "outline:20:200"},
  {color: "orange", effect: "outline:15:200"},
  {color: "yellow", effect: "outline:10:200"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("shoes.png", {transformation: [
  {width: 200, crop: "scale"},
  {color: "red", effect: "outline:20:200"},
  {color: "orange", effect: "outline:15:200"},
  {color: "yellow", effect: "outline:10:200"}
  ]})
React:
Copy to clipboard
<Image publicId="shoes.png" >
  <Transformation width="200" crop="scale" />
  <Transformation color="red" effect="outline:20:200" />
  <Transformation color="orange" effect="outline:15:200" />
  <Transformation color="yellow" effect="outline:10:200" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="shoes.png" >
  <cld-transformation width="200" crop="scale" />
  <cld-transformation color="red" effect="outline:20:200" />
  <cld-transformation color="orange" effect="outline:15:200" />
  <cld-transformation color="yellow" effect="outline:10:200" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="shoes.png" >
  <cl-transformation width="200" crop="scale">
  </cl-transformation>
  <cl-transformation color="red" effect="outline:20:200">
  </cl-transformation>
  <cl-transformation color="orange" effect="outline:15:200">
  </cl-transformation>
  <cl-transformation color="yellow" effect="outline:10:200">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(200).Crop("scale").Chain()
  .Color("red").Effect("outline:20:200").Chain()
  .Color("orange").Effect("outline:15:200").Chain()
  .Color("yellow").Effect("outline:10:200")).BuildImageTag("shoes.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setWidth(200).setCrop("scale").chain()
  .setColor("red").setEffect("outline:20:200").chain()
  .setColor("orange").setEffect("outline:15:200").chain()
  .setColor("yellow").setEffect("outline:10:200")).generate("shoes.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .width(200).crop("scale").chain()
  .color("red").effect("outline:20:200").chain()
  .color("orange").effect("outline:15:200").chain()
  .color("yellow").effect("outline:10:200")).generate("shoes.png");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("shoes.png")
   resize(Resize.scale() { width(200) })
   effect(Effect.outline() { width(20)
 blurLevel(200)
   color(Color.RED)
   })
   effect(Effect.outline() { width(15)
 blurLevel(200)
   color(Color.ORANGE)
   })
   effect(Effect.outline() { width(10)
 blurLevel(200)
   color(Color.YELLOW)
   }) 
}.generate()
multiple outlines

See full syntax: e_outline in the Transformation Reference.

Replace color

You can replace a color in an image using the replace_color effect. Unless you specify otherwise, the most prominent high-saturation color in an image is selected as the color to change. By default, a tolerance of 50 is applied to this color, representing a radius in the LAB color space, so that similar shades are also replaced, achieving a more natural effect.

For example, without specifying a color to change, the most prominent color is changed to the specified maroon:

Ruby:
Copy to clipboard
cl_image_tag("blue_burlap.png", :effect=>"replace_color:maroon")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('blue_burlap.png'))
  ->adjust(Adjust::replaceColor(Color::MAROON));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("blue_burlap.png", array("effect"=>"replace_color:maroon"))
Python:
Copy to clipboard
CloudinaryImage("blue_burlap.png").image(effect="replace_color:maroon")
Node.js:
Copy to clipboard
cloudinary.image("blue_burlap.png", {effect: "replace_color:maroon"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("replace_color:maroon")).imageTag("blue_burlap.png");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("blue_burlap.png").adjust(replaceColor("maroon"));
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('blue_burlap.png', {effect: "replace_color:maroon"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("blue_burlap.png", {effect: "replace_color:maroon"})
React:
Copy to clipboard
<Image publicId="blue_burlap.png" >
  <Transformation effect="replace_color:maroon" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="blue_burlap.png" >
  <cld-transformation effect="replace_color:maroon" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="blue_burlap.png" >
  <cl-transformation effect="replace_color:maroon">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("replace_color:maroon")).BuildImageTag("blue_burlap.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("replace_color:maroon")).generate("blue_burlap.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("replace_color:maroon")).generate("blue_burlap.png");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("blue_burlap.png")
   adjust(Adjust.replaceColor(Color.MAROON)) 
}.generate()

Original image with blue color Original blue bag Predominant color recolored to maroon shades Predominant color recolored

Adding a tolerance value of 10 (e_replace_color:maroon:10) prevents the handle also changing color:

Ruby:
Copy to clipboard
cl_image_tag("blue_burlap.png", :effect=>"replace_color:maroon:10")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('blue_burlap.png'))
  ->adjust(Adjust::replaceColor(Color::MAROON)->tolerance(10));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("blue_burlap.png", array("effect"=>"replace_color:maroon:10"))
Python:
Copy to clipboard
CloudinaryImage("blue_burlap.png").image(effect="replace_color:maroon:10")
Node.js:
Copy to clipboard
cloudinary.image("blue_burlap.png", {effect: "replace_color:maroon:10"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("replace_color:maroon:10")).imageTag("blue_burlap.png");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("blue_burlap.png").adjust(
  replaceColor("maroon").tolerance(10)
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('blue_burlap.png', {effect: "replace_color:maroon:10"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("blue_burlap.png", {effect: "replace_color:maroon:10"})
React:
Copy to clipboard
<Image publicId="blue_burlap.png" >
  <Transformation effect="replace_color:maroon:10" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="blue_burlap.png" >
  <cld-transformation effect="replace_color:maroon:10" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="blue_burlap.png" >
  <cl-transformation effect="replace_color:maroon:10">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("replace_color:maroon:10")).BuildImageTag("blue_burlap.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("replace_color:maroon:10")).generate("blue_burlap.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("replace_color:maroon:10")).generate("blue_burlap.png");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("blue_burlap.png")
   adjust(Adjust.replaceColor(Color.MAROON) { tolerance(10) }) 
}.generate()

Original image with blue color Original blue bag Handle not recolored Handle not recolored

Specifying blue as the color to replace (to a tolerance of 80 from the color #2b38aa) replaces the blue sides with parallel shades of maroon, taking into account shadows, lighting, etc:

Ruby:
Copy to clipboard
cl_image_tag("blue_burlap.png", :effect=>"replace_color:maroon:80:2b38aa")
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('blue_burlap.png'))
  ->adjust(Adjust::replaceColor(Color::MAROON)
  ->fromColor(Color::rgb("2b38aa"))
->tolerance(80));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("blue_burlap.png", array("effect"=>"replace_color:maroon:80:2b38aa"))
Python:
Copy to clipboard
CloudinaryImage("blue_burlap.png").image(effect="replace_color:maroon:80:2b38aa")
Node.js:
Copy to clipboard
cloudinary.image("blue_burlap.png", {effect: "replace_color:maroon:80:2b38aa"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("replace_color:maroon:80:2b38aa")).imageTag("blue_burlap.png");
JS (js-url-gen v1.x):
Copy to clipboard
new CloudinaryImage("blue_burlap.png").adjust(
  replaceColor("maroon")
    .fromColor("#2b38aa")
    .tolerance(80)
);
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('blue_burlap.png', {effect: "replace_color:maroon:80:2b38aa"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("blue_burlap.png", {effect: "replace_color:maroon:80:2b38aa"})
React:
Copy to clipboard
<Image publicId="blue_burlap.png" >
  <Transformation effect="replace_color:maroon:80:2b38aa" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="blue_burlap.png" >
  <cld-transformation effect="replace_color:maroon:80:2b38aa" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="blue_burlap.png" >
  <cl-transformation effect="replace_color:maroon:80:2b38aa">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("replace_color:maroon:80:2b38aa")).BuildImageTag("blue_burlap.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("replace_color:maroon:80:2b38aa")).generate("blue_burlap.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("replace_color:maroon:80:2b38aa")).generate("blue_burlap.png");
Kotlin:
Copy to clipboard
cloudinary.image {
  publicId("blue_burlap.png")
   adjust(Adjust.replaceColor(Color.MAROON) {
   fromColor(Color.rgb("2b38aa"))
 tolerance(80) }) 
}.generate()

Original image with blue color Original blue bag Blues recolored to maroon shades Blues recolored to maroon shades

See full syntax: e_replace_color in the Transformation Reference.

Rotation

Rotate an image by any arbitrary angle in degrees with the angle parameter (a in URLs). A positive integer value rotates the image clockwise, and a negative integer value rotates the image counterclockwise. If the angle is not a multiple of 90 then a rectangular bounding box is added containing the rotated image and empty space.

Note
If either the width or height of an image exceeds 3000 pixels, the image is automatically downscaled first, and then rotated. This applies to the image that is the input to the rotation, be it the output of a chained transformation or the original image.

Other possible rotation values instead of an integer value include:

  • auto_right - Rotate the image 90 degrees clockwise only if the requested aspect ratio does not match the image's aspect ratio.
  • auto_left - Rotate the image 90 degrees counterclockwise only if the requested aspect ratio does not match the image's aspect ratio.
  • vflip - Vertical mirror flip of the image.
  • hflip - Horizontal mirror flip of the image.
  • ignore - By default, the image is automatically rotated according to the EXIF data stored by the camera when the image was taken. Set the rotation to 'ignore' if you do not want the image to be automatically rotated.

Note
To apply multiple values, separate each value with a dot (.). For example to horizontally flip the image and rotate it by 45 degrees: angle: hflip.45

Examples with the uploaded image named sample (all images are also scaled down to a width of 100 pixels):

  1. Rotate the image by 90 degrees:
    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>100, :crop=>"scale"},
      {:angle=>90}
      ])
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->resize(Resize::scale()->width(100))
      ->rotate(Rotate::byAngle(90));
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>100, "crop"=>"scale"),
      array("angle"=>90)
      )))
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(transformation=[
      {'width': 100, 'crop': "scale"},
      {'angle': 90}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {transformation: [
      {width: 100, crop: "scale"},
      {angle: 90}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .width(100).crop("scale").chain()
      .angle(90)).imageTag("sample.jpg");
    JS (js-url-gen v1.x):
    Copy to clipboard
    new CloudinaryImage("sample.jpg")
      .resize(scale().width(100))
      .rotate(byAngle(90));
    JS (cloudinary-core v2.x (legacy)):
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {transformation: [
      {width: 100, crop: "scale"},
      {angle: 90}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 100, crop: "scale"},
      {angle: 90}
      ]})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation width="100" crop="scale" />
      <Transformation angle="90" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation width="100" crop="scale" />
      <cld-transformation angle="90" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation width="100" crop="scale">
      </cl-transformation>
      <cl-transformation angle="90">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(100).Crop("scale").Chain()
      .Angle(90)).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setWidth(100).setCrop("scale").chain()
      .setAngle(90)).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .width(100).crop("scale").chain()
      .angle(90)).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
      publicId("sample.jpg")
       resize(Resize.scale() { width(100) })
       rotate(Rotate.byAngle(90)) 
    }.generate()
    Image rotated 90 degrees clockwise
  2. Rotate the image by -20 degrees (automatically adds a bounding box):
    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>100, :crop=>"scale"},
      {:angle=>-20}
      ])
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->resize(Resize::scale()->width(100))
      ->rotate(Rotate::byAngle(-20));
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>100, "crop"=>"scale"),
      array("angle"=>-20)
      )))
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(transformation=[
      {'width': 100, 'crop': "scale"},
      {'angle': -20}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {transformation: [
      {width: 100, crop: "scale"},
      {angle: -20}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .width(100).crop("scale").chain()
      .angle(-20)).imageTag("sample.jpg");
    JS (js-url-gen v1.x):
    Copy to clipboard
    new CloudinaryImage("sample.jpg")
      .resize(scale().width(100))
      .rotate(byAngle(-20));
    JS (cloudinary-core v2.x (legacy)):
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {transformation: [
      {width: 100, crop: "scale"},
      {angle: -20}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 100, crop: "scale"},
      {angle: -20}
      ]})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation width="100" crop="scale" />
      <Transformation angle="-20" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation width="100" crop="scale" />
      <cld-transformation angle="-20" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation width="100" crop="scale">
      </cl-transformation>
      <cl-transformation angle="-20">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(100).Crop("scale").Chain()
      .Angle(-20)).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setWidth(100).setCrop("scale").chain()
      .setAngle(-20)).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .width(100).crop("scale").chain()
      .angle(-20)).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
      publicId("sample.jpg")
       resize(Resize.scale() { width(100) })
       rotate(Rotate.byAngle(-20)) 
    }.generate()
    Image rotated 20 degrees counterclockwise
  3. Vertically mirror flip the image and rotate by 45 degrees (automatically adds a bounding box):
    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>100, :crop=>"scale"},
      {:angle=>"vflip"},
      {:angle=>45}
      ])
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->resize(Resize::scale()->width(100))
      ->rotate(Rotate::mode(
      RotationMode::verticalFlip()))
      ->rotate(Rotate::byAngle(45));
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>100, "crop"=>"scale"),
      array("angle"=>"vflip"),
      array("angle"=>45)
      )))
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(transformation=[
      {'width': 100, 'crop': "scale"},
      {'angle': "vflip"},
      {'angle': 45}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {transformation: [
      {width: 100, crop: "scale"},
      {angle: "vflip"},
      {angle: 45}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .width(100).crop("scale").chain()
      .angle("vflip").chain()
      .angle(45)).imageTag("sample.jpg");
    JS (js-url-gen v1.x):
    Copy to clipboard
    new CloudinaryImage("sample.jpg")
      .resize(scale().width(100))
      .rotate(mode(verticalFlip()))
      .rotate(byAngle(45));
    JS (cloudinary-core v2.x (legacy)):
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {transformation: [
      {width: 100, crop: "scale"},
      {angle: "vflip"},
      {angle: 45}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 100, crop: "scale"},
      {angle: "vflip"},
      {angle: 45}
      ]})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation width="100" crop="scale" />
      <Transformation angle="vflip" />
      <Transformation angle="45" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation width="100" crop="scale" />
      <cld-transformation angle="vflip" />
      <cld-transformation angle="45" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation width="100" crop="scale">
      </cl-transformation>
      <cl-transformation angle="vflip">
      </cl-transformation>
      <cl-transformation angle="45">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(100).Crop("scale").Chain()
      .Angle("vflip").Chain()
      .Angle(45)).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setWidth(100).setCrop("scale").chain()
      .setAngle("vflip").chain()
      .setAngle(45)).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .width(100).crop("scale").chain()
      .angle("vflip").chain()
      .angle(45)).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    cloudinary.image {
      publicId("sample.jpg")
       resize(Resize.scale() { width(100) })
       rotate(Rotate.mode(
      RotationMode.verticalFlip()))
       rotate(Rotate.byAngle(45)) 
    }.generate()
    Image vertically flipped and rotated 45 degrees clockwise
  4. Crop the image to a 200x200 circle, then rotate the image by 30 degrees (automatically adds a bounding box) and finally trim the extra whitespace added:
    Ruby:
    Copy to clipboard
    cl_image_tag("sample.jpg", :transformation=>[
      {:height=>200, :width=>200, :crop=>"fill"},
      {:radius=>"max"},
      {:angle=>30},
      {:effect=>"trim"}
      ])
    PHP (cloudinary_php v2.x):
    Copy to clipboard
    (new ImageTag('sample.jpg'))
      ->resize(Resize::fill()->width(200)
    ->height(200))
      ->roundCorners(RoundCorners::max())
      ->rotate(Rotate::byAngle(30))
      ->reshape(Reshape::trim());
    PHP (cloudinary_php v1.x (legacy)):
    Copy to clipboard
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("height"=>200, "width"=>200, "crop"=>"fill"),
      array("radius"=>"max"),
      array("angle"=>30),
      array("effect"=>"trim")
      )))
    Python:
    Copy to clipboard
    CloudinaryImage("sample.jpg").image(transformation=[
      {'height': 200, 'width': 200, 'crop': "fill"},
      {'radius': "max"},
      {'angle': 30},
      {'effect': "trim"}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("sample.jpg", {transformation: [
      {height: 200, width: 200, crop: "fill"},
      {radius: "max"},
      {angle: 30},
      {effect: "trim"}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .height(200).width(200).crop("fill").chain()
      .radius("max").chain()
      .angle(30).chain()
      .effect("trim")).imageTag("sample.jpg");
    JS (js-url-gen v1.x):
    Copy to clipboard
    // This code example is not currently available.
    JS (cloudinary-core v2.x (legacy)):
    Copy to clipboard
    cloudinary.imageTag('sample.jpg', {transformation: [
      {height: 200, width: 200, crop: "fill"},
      {radius: "max"},
      {angle: 30},
      {effect: "trim"}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("sample.jpg", {transformation: [
      {height: 200, width: 200, crop: "fill"},
      {radius: "max"},
      {angle: 30},
      {effect: "trim"}
      ]})
    React:
    Copy to clipboard
    <Image publicId="sample.jpg" >
      <Transformation height="200" width="200" crop="fill" />
      <Transformation radius="max" />
      <Transformation angle="30" />
      <Transformation effect="trim" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image public-id="sample.jpg" >
      <cld-transformation height="200" width="200" crop="fill" />
      <cld-transformation radius="max" />
      <cld-transformation angle="30" />
      <cld-transformation effect="trim" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="sample.jpg" >
      <cl-transformation height="200" width="200" crop="fill">
      </cl-transformation>
      <cl-transformation radius="max">
      </cl-transformation>
      <cl-transformation angle="30">
      </cl-transformation>
      <cl-transformation effect="trim">
      </cl-transformation>
    </cl-image>
    .NET:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Height(200).Width(200).Crop("fill").Chain()
      .Radius("max").Chain()
      .Angle(30).Chain()
      .Effect("trim")).BuildImageTag("sample.jpg")
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setHeight(200).setWidth(200).setCrop("fill").chain()
      .setRadius("max").chain()
      .setAngle(30).chain()
      .setEffect("trim")).generate("sample.jpg")!, cloudinary: cloudinary)
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .height(200).width(200).crop("fill").chain()
      .radius("max").chain()
      .angle(30).chain()
      .effect("trim")).generate("sample.jpg");
    Kotlin:
    Copy to clipboard
    // This code example is not currently available.
    image cropped to a 200x200 circle, rotated 30 degrees clockwise and trimmed

See full syntax: a (angle) in the Transformation Reference.

Rounding

Many website designs need images with rounded corners, while some websites require images with a complete circular or oval (ellipse) crop. Twitter, for example, uses rounded corners for its users' profile pictures.

Programmatically, rounded corners can be achieved using the original rectangular images combined with modern CSS properties or image masking overlays. However, it is sometimes useful to deliver images with rounded corners in the first place. This is particularly helpful when you want to embed images inside an email (most mail clients can't add CSS based rounded corners), a PDF or a mobile application. Delivering images with already rounded corners is also useful if you want to simplify your CSS and markup or when you need to support older browsers.

Transforming an image to a rounded version is done using the radius parameter (r in URLs). You can manually specify the amount to round various corners, or you can set it to automatically round to an exact ellipse or circle.

Note
To deliver a rounded image with a transparent background, deliver as PNG. Formats that do not support transparency will be delivered by default with a white background, which can be adjusted with the background transformation parameter. Keep in mind that the PNG format produces larger files than the JPEG format. For more information, see the article on PNG optimization - saving bandwidth on transparent PNGs with dynamic underlay.

Manually setting rounding values

To manually control the rounding, use the radius parameter with between 1 and 4 values defining the rounding amount (in pixels, separated by colons), following the same concept as the border-radius CSS property. When specifying multiple values, keep a corner untouched by specifying '0'.

  • One value: Symmetrical. All four corners are rounded equally according to the specified value.
  • Two values: Opposites are symmetrical. The first value applies to the top-left and bottom-right corners. The second value applies to the top-right and bottom-left corners.
  • Three values: One set of corners is symmetrical. The first value applies to the top-left. The second value applies to the top-right and bottom-left corners. The third value applies to the bottom-right.
  • Four values: The rounding for each corner is specified separately, in clockwise order, starting with the top-left.

For example:

1 value: r_20 r_20 2 values: r_25:0 r_25:0    3 values: r_10:40:25 r_10:40:25    4 values: r_30:0:30:30 r_30:0:30:30   

Ruby:
Copy to clipboard
cl_image_tag("Pi.png", :transformation=>[
  {:height=>100, :width=>150, :crop=>"fill"},
  {:radius=>"25:0"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('Pi.png'))
  ->resize(Resize::fill()->width(150)
->height(100))
  ->roundCorners(RoundCorners::byRadius(25,0));
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("Pi.png", array("transformation"=>array(
  array("height"=>100, "width"=>150, "crop"=>"fill"),
  array("radius"=>"25:0")
  )))
Python:
Copy to clipboard
CloudinaryImage("Pi.png").image(transformation=[
  {'height': 100, 'width': 150, 'crop': "fill"},
  {'radius': "25:0"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("Pi.png", {transformation: [
  {height: 100, width: 150, crop: "fill"},
  {radius: "25:0"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .height(100).width(150).crop("fill").chain()
  .radius("25:0")).imageTag("Pi.png");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('Pi.png', {transformation: [
  {height: 100, width: 150, crop: "fill"},
  {radius: "25:0"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("Pi.png", {transformation: [
  {height: 100, width: 150, crop: "fill"},
  {radius: "25:0"}
  ]})
React:
Copy to clipboard
<Image publicId="Pi.png" >
  <Transformation height="100" width="150" crop="fill" />
  <Transformation radius="25:0" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="Pi.png" >
  <cld-transformation height="100" width="150" crop="fill" />
  <cld-transformation radius="25:0" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="Pi.png" >
  <cl-transformation height="100" width="150" crop="fill">
  </cl-transformation>
  <cl-transformation radius="25:0">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Height(100).Width(150).Crop("fill").Chain()
  .Radius("25:0")).BuildImageTag("Pi.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setHeight(100).setWidth(150).setCrop("fill").chain()
  .setRadius("25:0")).generate("Pi.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .height(100).width(150).crop("fill").chain()
  .radius("25:0")).generate("Pi.png");
Kotlin:
Copy to clipboard
// This code example is not currently available.

Automatically rounding to an ellipse or circle

Rather than specifying specific rounding values, you can automatically crop images to the shape of an ellipse (if the requested image size is a rectangle) or a circle (if the requested image size is a square). Simply pass max as the value of the radius parameter instead of numeric values.

The following example transforms an uploaded JPEG to a 250x150 PNG with maximum radius cropping, which generates the ellipse shape with a transparent background:

Ruby:
Copy to clipboard
cl_image_tag("pi.png", :transformation=>[
  {:height=>150, :width=>250, :crop=>"fill"},
  {:radius=>"max"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('pi.png'))
  ->resize(Resize::fill()->width(250)
->height(150))
  ->roundCorners(RoundCorners::max());
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("pi.png", array("transformation"=>array(
  array("height"=>150, "width"=>250, "crop"=>"fill"),
  array("radius"=>"max")
  )))
Python:
Copy to clipboard
CloudinaryImage("pi.png").image(transformation=[
  {'height': 150, 'width': 250, 'crop': "fill"},
  {'radius': "max"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("pi.png", {transformation: [
  {height: 150, width: 250, crop: "fill"},
  {radius: "max"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .height(150).width(250).crop("fill").chain()
  .radius("max")).imageTag("pi.png");
JS (js-url-gen v1.x):
Copy to clipboard
// This code example is not currently available.
JS (cloudinary-core v2.x (legacy)):
Copy to clipboard
cloudinary.imageTag('pi.png', {transformation: [
  {height: 150, width: 250, crop: "fill"},
  {radius: "max"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("pi.png", {transformation: [
  {height: 150, width: 250, crop: "fill"},
  {radius: "max"}
  ]})
React:
Copy to clipboard
<Image publicId="pi.png" >
  <Transformation height="150" width="250" crop="fill" />
  <Transformation radius="max" />
</Image>
Vue.js:
Copy to clipboard
<cld-image public-id="pi.png" >
  <cld-transformation height="150" width="250" crop="fill" />
  <cld-transformation radius="max" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="pi.png" >
  <cl-transformation height="150" width="250" crop="fill">
  </cl-transformation>
  <cl-transformation radius="max">
  </cl-transformation>
</cl-image>
.NET:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Height(150).Width(250).Crop("fill").Chain()
  .Radius("max")).BuildImageTag("pi.png")
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setHeight(150).setWidth(250).setCrop("fill").chain()
  .setRadius("max")).generate("pi.png")!, cloudinary: cloudinary)
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .height(150).width(250).crop("fill").chain()
  .radius("max")).generate("pi.png");
Kotlin:
Copy to clipboard
// This code example is not currently available.
150x100 ellipsoid image

As the following example shows, displaying pictures of your web site's users as circle headshots is very easy to achieve with Cloudinary using face gravity with max radius:

Ruby:
Copy to clipboard
cl_image_tag("face_left.png", :transformation=>[
  {:gravity=>"face", :height=>200, :width=>200, :crop=>"thumb"},
  {:radius=>"max"}
  ])
PHP (cloudinary_php v2.x):
Copy to clipboard
(new ImageTag('face_left.png'))
  ->resize(Resize::thumbnail()->width(200)
->height(200)
  ->gravity(
  Gravity::focusOn(
  FocusOn::face()))
  )
  ->roundCorners(RoundCorners::max());
PHP (cloudinary_php v1.x (legacy)):
Copy to clipboard
cl_image_tag("face_left.png", array("transformation"=>array(
  array("gravity"=>"face", "height"=>200, "width"=>200, "crop"=>"thumb"),
  array("radius"=>"max")
  )))
Python:
Copy to clipboard
CloudinaryImage("face_left.png").image(transformation=[
  {'gravity': "face", 'height': 200, 'width': 200, 'crop': "thumb"},
  {'radius': "max"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("face_left.png", {transformation: [
  {gravity: "face", height: 200, width: 200, crop: "thumb"},
  {radius: "max"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .gravity("face").height(200