Image transformations

Whether your web application supports user uploaded images, you deliver static images, or you display profile pictures from social networks, you probably need to manipulate them to fit the graphic design of your Web site or mobile application.

For example, the following dynamic URL with on-the-fly image transformation crops an image to a 400x400 circular thumbnail while automatically focusing on the face, and then scales down the result to a width of 200 pixels. Below you can see the original image (scaled down) and the dynamically created face detection based thumbnail.

Sample lady image

Sample image using the crop, face detection, rounded corners and resize features

Ruby:
cl_image_tag("lady.jpg", :transformation=>[
  {:width=>400, :height=>400, :gravity=>"face", :radius=>"max", :crop=>"crop"},
  {:width=>200}
  ])
PHP:
cl_image_tag("lady.jpg", array("transformation"=>array(
  array("width"=>400, "height"=>400, "gravity"=>"face", "radius"=>"max", "crop"=>"crop"),
  array("width"=>200)
  )))
Python:
CloudinaryImage("lady.jpg").image(transformation=[
  {"width": 400, "height": 400, "gravity": "face", "radius": "max", "crop": "crop"},
  {"width": 200}
  ])
Node.js:
cloudinary.image("lady.jpg", {transformation: [
  {width: 400, height: 400, gravity: "face", radius: "max", crop: "crop"},
  {width: 200}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(400).height(400).gravity("face").radius("max").crop("crop").chain()
  .width(200)).imageTag("lady.jpg")
jQuery:
$.cloudinary.image("lady.jpg", {transformation: [
  {width: 400, height: 400, gravity: "face", radius: "max", crop: "crop"},
  {width: 200}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(400).Height(400).Gravity("face").Radius("max").Crop("crop").Chain()
  .Width(200)).BuildImageTag("lady.jpg")

Cloudinary allows you to easily transform your images on-the-fly to any required format, style and dimension, and also optimizes images to have the minimal file size for an improved user experience and for saving bandwidth. Doing so is done by implementing dynamic image transformation and delivery URLs for accessing the images. You can change the required transformations at any time and all transformed images will be created on-demand (lazily) and delivered to your users through a fast CDN with optimized caching.

You can specify the required height and width, define the way to crop the image, and select the image format that fits your needs. You can also use our face detection based cropping techniques for focusing on the most relevant part of user uploaded photos. For complex transformations, you can use the Management Console or Admin API for defining named transformations and even run a set of chained transformations on your images. You can also use the Management Console to view delivery usage reports and optimization insights.

Cloudinary's image management service supports the following image transformation and delivery capabilities:

The Image Transformations Reference table summarizes the extensive list of parameters available for manipulating images.

Cloudinary's client libraries (SDKs) take care of the transformation URL building for you, and simplify the integration even further. They allow you to continue working in your preferred developer framework and provide helper methods to simplify building image tags and image transformation URLs: Rails, PHP, Django, jQuery, Node.js, .NET, Java, Angular, Javascript, iOS, Scala and Android.

Delivering images using dynamic URLs

Accessing images is done using simple delivery HTTP or HTTPS URLs which are then delivered to users via a worldwide fast CDN. The URL contains the Public ID of the requested image plus any optional transformation parameters. Public ID is the unique identifier of the image and is either specified when uploading the image to your Cloudinary account, or automatically assigned by Cloudinary (see Upload images for more details on the various options for specifying the public ID).

The Cloudinary resource delivery URL takes the following structure:

http://res.cloudinary.com/<cloud_name>/<resource_type>/<type>/<version>/<public_id>.<format>

Where:

  • cloud_name - the name of your Cloudinary account, a unique public identifier for URL building and API access.
  • resource_type is the type of file to deliver. Valid values: image, raw, and video (note that there are other valid values when fetching remote images: see Fetching images from remote locations for more information).
  • type - the level of accessibility of the file to deliver. Valid values: upload, private and authenticated.
  • version - (optional) can be added to the delivery URL in order to bypass the cached version on the CDN and force delivery of the latest resource (in the case that a resource has been overwritten with a newer file). The version component is generally not included in the example URLs on this page in order to keep them simple. See Image versions for more information.
  • public_id - the unique identifier of the resource, including the folder structure if defined.
  • format - (optional) the file extension of the requested delivery format for the resource. The resource is delivered in the original uploaded format if the file extension is not included.

Therefore, in the most general case of delivering an image that has been uploaded to your Cloudinary account, the delivery URL is given as:

http://res.cloudinary.com/<cloud_name>/image/upload/<public_id>.<format>

For example, displaying the image with a public ID of sample uploaded to Cloudinary's demo account in jpg format:

Ruby:
cl_image_tag("sample.jpg")
PHP:
cl_image_tag("sample.jpg")
Python:
CloudinaryImage("sample.jpg").image()
Node.js:
cloudinary.image("sample.jpg")
Java:
cloudinary.url().imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg")
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("sample.jpg")
Sample image

Any transformation (manipulation) instructions can be added before the public ID in the delivery URL. When the URL is first accessed, the derived image is created on-the-fly and delivered to your user. The derived image is also cached on the CDN and is immediately available to all subsequent users requesting the same image. The image delivery URL with transformation parameters takes the following structure:

http://res.cloudinary.com/<cloud name>/image/upload/<transformation parameters>/<public ID>.<image format file extension>

Following is an example of delivering an image with transformation parameters, where the image with a public ID of sample is cropped to a width of 300 pixels and a height of 200 pixels, and delivered in JPEG format:

Ruby:
cl_image_tag("sample.jpg", :width=>300, :height=>200, :crop=>"crop")
PHP:
cl_image_tag("sample.jpg", array("width"=>300, "height"=>200, "crop"=>"crop"))
Python:
CloudinaryImage("sample.jpg").image(width=300, height=200, crop="crop")
Node.js:
cloudinary.image("sample.jpg", {width: 300, height: 200, crop: "crop"})
Java:
cloudinary.url().transformation(new Transformation().width(300).height(200).crop("crop")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 300, height: 200, crop: "crop"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(300).Height(200).Crop("crop")).BuildImageTag("sample.jpg")
Image cropped to 300x200

You can also use shortcut URLs for specifically delivering uploaded images. With Cloudinary’s Root Path URL feature, the resource type and type parameters can be omitted from the URL (they automatically default to the values 'image' and 'upload' respectively). For example, the Root Path shortcut delivery URL for the cropped image above is:

http://res.cloudinary.com/demo/w_300,h_200,c_crop/sample.jpg

The rest of this page documents the various transformation and delivery options, and you can also see the Image Transformations Reference table for an overview on the extensive list of possible parameters and their values.

Secure HTTPS URLs

Cloudinary supports delivering images using HTTPS URLs. The process for creating HTTPS delivery URLs is identical to creating HTTP URLs, with only the URL protocol changing. When using one of Cloudinary's framework SDKs, you can generate HTTPS URLs by setting the secure parameter to true, either globally (e.g., in the CLOUDINARY_URL environment variable) or locally in each call. For example, delivering the sample image with HTTPS:

Ruby:
cl_image_tag("sample.jpg", :secure=>true)
PHP:
cl_image_tag("sample.jpg", array("secure"=>true))
Python:
CloudinaryImage("sample.jpg").image(secure=True)
Node.js:
cloudinary.image("sample.jpg", {secure: true})
Java:
cloudinary.url().secure(true).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {secure: true})
.Net:
cloudinary.Api.UrlImgUp.Secure(true).BuildImageTag("sample.jpg")
HTTPS delivered image

For more information on using HTTPS to deliver your images, see the article on Why isn't everyone using HTTPS and how to do it with Cloudinary.

Embedding images in web pages

Accessing uploaded images or their derived transformations is done using simple URLs that you can use as the 'src' of the 'img' tags in your HTML code or Javascript functions. URLs for accessing resources contain the resource kind, the Public ID of the resource, and optional version and transformation parameters. You can also use Cloudinary’s web framework SDKs to aid you in adding images to your web application and simplify the creation of transformation URLs and embedding HTML image tags. Cloudinary offers two main helper methods in this regard:

The Cloudinary URL helper method (e.g. cloudinary_url in Ruby on Rails) automatically generates the image source URL for use as the 'src' of the 'img' tags in your HTML code or Javascript functions. For example, using the URL helper method to return the URL of the sample image, scaled to a width of 300 pixels and a height of 100 pixels:

Ruby:
cloudinary_url("sample.jpg", :width=>300, :height=>100, :crop=>"scale", :secure=>true)
PHP:
Cloudinary::cloudinary_url("sample.jpg", array("width"=>300, "height"=>100, "crop"=>"scale", "secure"=>true))
Python:
cloudinary.utils.cloudinary_url("sample.jpg", width=300, height=100, crop="scale", secure=True)
Node.js:
cloudinary.url("sample.jpg", {width: 300, height: 100, crop: "scale", secure: true})
Java:
cloudinary.url().transformation(new Transformation().width(300).height(100).crop("scale")).secure(true).generate("sample.jpg")
jQuery:
$.cloudinary.url("sample.jpg", {width: 300, height: 100, crop: "scale", secure: true})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(300).Height(100).Crop("scale")).Secure(true).BuildUrl("sample.jpg")

The Cloudinary Image Tag helper method (e.g. cl_image_tag in Ruby on Rails) automatically generates an HTML image tag including the image source URL. For example, using the Image Tag helper method to create an HTML image tag for the sample image, scaled to a width of 300 pixels and a height of 100 pixels:

Ruby:
cl_image_tag("sample.jpg", :width=>300, :height=>100, :crop=>"scale", :secure=>true)
PHP:
cl_image_tag("sample.jpg", array("width"=>300, "height"=>100, "crop"=>"scale", "secure"=>true))
Python:
CloudinaryImage("sample.jpg").image(width=300, height=100, crop="scale", secure=True)
Node.js:
cloudinary.image("sample.jpg", {width: 300, height: 100, crop: "scale", secure: true})
Java:
cloudinary.url().transformation(new Transformation().width(300).height(100).crop("scale")).secure(true).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 300, height: 100, crop: "scale", secure: true})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(300).Height(100).Crop("scale")).Secure(true).BuildImageTag("sample.jpg")

The Cloudinary Image Tag helper method allows you to not only specify any Cloudinary transformations parameters, but also to specify regular HTML image tag attributes (e.g., alt, title, width, height).

Notes:

  • Specifying the width and height parameters without a crop mode will add them as parameters of the HTML img tag, and specifying the width and height parameters with a crop mode will add them as transformation parameters to the image source URL. In this case you can use the html_width and html_height parameters if you need different dimensions for the HTML img tag.
  • Using a full URL (e.g., http://res.cloudinary.com/demo/image/upload/sample.jpg) instead of only the public ID (e.g., sample.jpg) in the first parameter of the helper methods will result in all other parameters of the helper method being ignored and only using the full URL as the final generated URL.

For more information on these helper methods, see the documentation for the relevant framework: Ruby on Rails, PHP, Django, Node.js, Java, .NET, Angular, Javascript, iOS, Scala and Android.

Resizing and cropping images

You can resize and crop images in order to match the graphic design of your web site or mobile application. Whether images are uploaded in your server-side code or by your users, the original hi-res images are stored in the cloud for further processing and management. You can then dynamically create multiple resized, cropped and manipulated images on-the-fly and deliver them via dynamic URLs.

To change the size of a image, use the width and height parameters (w and h in URLs) to assign new values. You can resize the image by using both the width and height parameters or with only one of them: the other dimension is automatically updated to maintain the aspect ratio.

  • Using an integer value sets the new dimension to that number in pixels. For example, w_150 sets the width to exactly 150 pixels.
  • Using a decimal value sets the new dimension as a multiple of the original dimension. For example, w_0.5 sets the width to half the original width.
  • Using oh or ow as values sets the dimension to the original height or original width respectively. For example, w_ow sets the width to the same value as the original width. This may be useful when applying chained transformations or setting the dimensions of an overlay.

Examples of resizing the uploaded jpg image named sample:

  1. Resizing the width to half the original width, maintaining the aspect ratio:

    Ruby:
    cl_image_tag("sample.jpg", :width=>0.5)
    PHP:
    cl_image_tag("sample.jpg", array("width"=>0.5))
    Python:
    CloudinaryImage("sample.jpg").image(width=0.5)
    Node.js:
    cloudinary.image("sample.jpg", {width: 0.5})
    Java:
    cloudinary.url().transformation(new Transformation().width(0.5)).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 0.5})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(0.5)).BuildImageTag("sample.jpg")
    Image scaled to half width

  2. Resizing the height to 200 pixels, maintaining the aspect ratio:

    Ruby:
    cl_image_tag("sample.jpg", :height=>200)
    PHP:
    cl_image_tag("sample.jpg", array("height"=>200))
    Python:
    CloudinaryImage("sample.jpg").image(height=200)
    Node.js:
    cloudinary.image("sample.jpg", {height: 200})
    Java:
    cloudinary.url().transformation(new Transformation().height(200)).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {height: 200})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Height(200)).BuildImageTag("sample.jpg")
    Image scaled to a height of 200 pixels

  3. Resizing to a width of 200 pixels and a height of 100 pixels:

    Ruby:
    cl_image_tag("sample.jpg", :width=>200, :height=>100)
    PHP:
    cl_image_tag("sample.jpg", array("width"=>200, "height"=>100))
    Python:
    CloudinaryImage("sample.jpg").image(width=200, height=100)
    Node.js:
    cloudinary.image("sample.jpg", {width: 200, height: 100})
    Java:
    cloudinary.url().transformation(new Transformation().width(200).height(100)).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 200, height: 100})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(100)).BuildImageTag("sample.jpg")
    Image scaled to 200x100

When changing the dimensions of an uploaded image by manipulating the image's height and/or width, you need to decide how to adapt or "crop" the image to fit into the requested size. Use the crop parameter for selecting the crop mode (c in URLs). Cloudinary supports the following image cropping modes: scale, fit, mfit, fill, lfill, limit, pad, lpad, mpad, crop, thumb, imagga_crop and imagga_scale.

Note: When creating dynamic delivery URLs, the image is scaled to the new dimensions by default (as in the examples above), unless a different cropping mode is selected. However, there is no default value when using the Cloudinary SDK helper methods (see Embedding images in web pages), and a cropping mode must be explicitly selected.

scale

Change the size of the image exactly to the given width and height without necessarily retaining the original aspect ratio: all original image parts are visible but might be stretched or shrunk. If only the width or height is given, then the image is scaled to the new dimension while retaining the original aspect ratio, unless you also include the ignore_aspect_ratio flag). This is the default cropping mode for resizing images if the crop mode is not specified.

Examples of scaling the uploaded image named sample:

  1. Scaled to a width of 150 pixels (maintains the aspect ratio by default):

    Ruby:
    cl_image_tag("sample.jpg", :width=>150, :crop=>"scale")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>150, "crop"=>"scale"))
    Python:
    CloudinaryImage("sample.jpg").image(width=150, crop="scale")
    Node.js:
    cloudinary.image("sample.jpg", {width: 150, crop: "scale"})
    Java:
    cloudinary.url().transformation(new Transformation().width(150).crop("scale")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 150, crop: "scale"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Crop("scale")).BuildImageTag("sample.jpg")
    Image scaled to a width of 150 pixels

  2. Scaled to a width and height of 150 pixels without maintaining the aspect ratio:

    Ruby:
    cl_image_tag("sample.jpg", :width=>150, :height=>150, :crop=>"scale")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>150, "height"=>150, "crop"=>"scale"))
    Python:
    CloudinaryImage("sample.jpg").image(width=150, height=150, crop="scale")
    Node.js:
    cloudinary.image("sample.jpg", {width: 150, height: 150, crop: "scale"})
    Java:
    cloudinary.url().transformation(new Transformation().width(150).height(150).crop("scale")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 150, height: 150, crop: "scale"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(150).Crop("scale")).BuildImageTag("sample.jpg")
    Image scaled to a width and height of 150 pixels

  3. Scaled to a width of 25% (maintains the aspect ratio by default):

    Ruby:
    cl_image_tag("sample.jpg", :width=>0.25, :crop=>"scale")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>0.25, "crop"=>"scale"))
    Python:
    CloudinaryImage("sample.jpg").image(width=0.25, crop="scale")
    Node.js:
    cloudinary.image("sample.jpg", {width: 0.25, crop: "scale"})
    Java:
    cloudinary.url().transformation(new Transformation().width(0.25).crop("scale")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 0.25, crop: "scale"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(0.25).Crop("scale")).BuildImageTag("sample.jpg")
    Image scaled to a width of 25%

fit

The image is resized so that it takes up as much space as possible within a bounding box defined by the given width and height parameters. The original aspect ratio is retained and all of the original image is visible.

For example, the uploaded image named sample is resized to fit within a width and height of 250 pixels while retaining the aspect ratio:

Ruby:
cl_image_tag("sample.jpg", :width=>250, :height=>250, :crop=>"fit")
PHP:
cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "crop"=>"fit"))
Python:
CloudinaryImage("sample.jpg").image(width=250, height=250, crop="fit")
Node.js:
cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "fit"})
Java:
cloudinary.url().transformation(new Transformation().width(250).height(250).crop("fit")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "fit"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Crop("fit")).BuildImageTag("sample.jpg")
Image fit to a width and height of 250 pixels

limit

Same as the fit mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down so that it takes up as much space as possible within a bounding box defined by the given width and height parameters. The original aspect ratio is retained and all of the original image is visible. This mode doesn't scale up the image if your requested dimensions are larger than the original image's.

For example, the uploaded jpg image named sample limited to a width and height of 250 pixels while retaining the aspect ratio:

Ruby:
cl_image_tag("sample.jpg", :width=>250, :height=>250, :crop=>"limit")
PHP:
cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "crop"=>"limit"))
Python:
CloudinaryImage("sample.jpg").image(width=250, height=250, crop="limit")
Node.js:
cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "limit"})
Java:
cloudinary.url().transformation(new Transformation().width(250).height(250).crop("limit")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "limit"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Crop("limit")).BuildImageTag("sample.jpg")
Image limited to a width and height of 250 pixels

mfit (minimum fit)

Same as the fit mode but only if the original image is smaller than the given minimum (width and height), in which case the image is scaled up so that it takes up as much space as possible within a bounding box defined by the given width and height parameters. The original aspect ratio is retained and all of the original image is visible. This mode doesn't scale down the image if your requested dimensions are smaller than the original image's.

For example, attempting to fit the uploaded image named sample to a minimum width and height of 250 pixels while retaining the aspect ratio, results in delivering the original larger image:

Ruby:
cl_image_tag("sample.jpg", :width=>250, :height=>250, :crop=>"mfit")
PHP:
cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "crop"=>"mfit"))
Python:
CloudinaryImage("sample.jpg").image(width=250, height=250, crop="mfit")
Node.js:
cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "mfit"})
Java:
cloudinary.url().transformation(new Transformation().width(250).height(250).crop("mfit")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "mfit"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Crop("mfit")).BuildImageTag("sample.jpg")
Image mfit to a width and height of 250 pixels

fill

Create an image with the exact given width and height while retaining the original aspect ratio, using only part of the image that fills the given dimensions if necessary (only part of the original image might be visible if the requested aspect ratio is different from the original aspect ratio). You can also specify which part of the original image to use for filling the required dimensions in case the proportions do not match by using the gravity parameter (set to center by default).

Examples of fill used with the uploaded jpg image named sample:

  1. Filled to a width and height of 250 pixels while retaining the aspect ratio:

    Ruby:
    cl_image_tag("sample.jpg", :width=>250, :height=>250, :crop=>"fill")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "crop"=>"fill"))
    Python:
    CloudinaryImage("sample.jpg").image(width=250, height=250, crop="fill")
    Node.js:
    cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "fill"})
    Java:
    cloudinary.url().transformation(new Transformation().width(250).height(250).crop("fill")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "fill"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Crop("fill")).BuildImageTag("sample.jpg")
    Image filled to a width and height of 250 pixels

  2. Filled to a width and height of 250 pixels with east gravity:

    Ruby:
    cl_image_tag("sample.jpg", :width=>250, :height=>250, :gravity=>"east", :crop=>"fill")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "gravity"=>"east", "crop"=>"fill"))
    Python:
    CloudinaryImage("sample.jpg").image(width=250, height=250, gravity="east", crop="fill")
    Node.js:
    cloudinary.image("sample.jpg", {width: 250, height: 250, gravity: "east", crop: "fill"})
    Java:
    cloudinary.url().transformation(new Transformation().width(250).height(250).gravity("east").crop("fill")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 250, height: 250, gravity: "east", crop: "fill"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Gravity("east").Crop("fill")).BuildImageTag("sample.jpg")
    Image filled to a width and height of 250 pixels with east gravity

lfill (limit fill)

Same as the fill mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down to fill the given width and height while retaining the original aspect ratio, using only part of the image that fills the given dimensions if necessary (only part of the original image might be visible if the requested aspect ratio is different from the original aspect ratio). You can also specify which part of the original image to use for filling the required dimensions in case the proportions do not match by using the gravity parameter. This mode doesn't scale up the image if your requested dimensions are bigger than the original image's.

For example, the uploaded image named sample limit filled to a width of 150 pixels and a height of 200 pixels while retaining the aspect ratio and limiting the size to no larger than the original image:

Ruby:
cl_image_tag("sample.jpg", :width=>150, :height=>200, :crop=>"lfill")
PHP:
cl_image_tag("sample.jpg", array("width"=>150, "height"=>200, "crop"=>"lfill"))
Python:
CloudinaryImage("sample.jpg").image(width=150, height=200, crop="lfill")
Node.js:
cloudinary.image("sample.jpg", {width: 150, height: 200, crop: "lfill"})
Java:
cloudinary.url().transformation(new Transformation().width(150).height(200).crop("lfill")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 150, height: 200, crop: "lfill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(200).Crop("lfill")).BuildImageTag("sample.jpg")
Image lfilled to a width of 150 and a height of 200 pixels

pad

Resize the image to fill the given width and height while retaining the original aspect ratio and with all of the original image visible. If the proportions of the original image do not match the given width and height, padding is added to the image to reach the required size. You can also specify where the original image is placed by using the gravity parameter (set to center by default), and specify the color of the background in the case that padding is added.

For example, the uploaded jpg image named sample padded with a black background to a width and height of 250 pixels:

Ruby:
cl_image_tag("sample.jpg", :width=>250, :height=>250, :background=>"black", :crop=>"pad")
PHP:
cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "background"=>"black", "crop"=>"pad"))
Python:
CloudinaryImage("sample.jpg").image(width=250, height=250, background="black", crop="pad")
Node.js:
cloudinary.image("sample.jpg", {width: 250, height: 250, background: "black", crop: "pad"})
Java:
cloudinary.url().transformation(new Transformation().width(250).height(250).background("black").crop("pad")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 250, height: 250, background: "black", crop: "pad"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Background("black").Crop("pad")).BuildImageTag("sample.jpg")
Image padded to a width and height of 250 pixels

lpad (limit pad)

Same as the pad mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down to fill the given width and height while retaining the original aspect ratio and with all of the original image visible. This mode doesn't scale up the image if your requested dimensions are bigger than the original image's. If the proportions of the original image do not match the given width and height, padding is added to the image to reach the required size. You can also specify where the original image is placed by using the gravity parameter (set to center by default), and specify the color of the background in the case that padding is added.

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

Ruby:
cl_image_tag("sample.jpg", :width=>400, :height=>150, :background=>"green", :crop=>"lpad")
PHP:
cl_image_tag("sample.jpg", array("width"=>400, "height"=>150, "background"=>"green", "crop"=>"lpad"))
Python:
CloudinaryImage("sample.jpg").image(width=400, height=150, background="green", crop="lpad")
Node.js:
cloudinary.image("sample.jpg", {width: 400, height: 150, background: "green", crop: "lpad"})
Java:
cloudinary.url().transformation(new Transformation().width(400).height(150).background("green").crop("lpad")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 400, height: 150, background: "green", crop: "lpad"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(400).Height(150).Background("green").Crop("lpad")).BuildImageTag("sample.jpg")
Image lpadded to a width and height of 250 pixels

mpad (minimum pad)

Same as the pad mode but only if the original image is smaller than the given minimum (width and height), in which case the image is scaled up to fill the given width and height while retaining the original aspect ratio and with all of the original image visible. This mode doesn't scale down the image if your requested dimensions are smaller than the original image's. If the proportions of the original image do not match the given width and height, padding is added to the image to reach the required size. You can also specify where the original image is placed by using the gravity parameter (set to center by default), and specify the color of the background in the case that padding is added.

For example, attempting to minimum pad the uploaded image named sample to a width and height of 250 pixels while retaining the aspect ratio, results in delivering the original larger image:

Ruby:
cl_image_tag("sample.jpg", :width=>250, :height=>250, :crop=>"mpad")
PHP:
cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "crop"=>"mpad"))
Python:
CloudinaryImage("sample.jpg").image(width=250, height=250, crop="mpad")
Node.js:
cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "mpad"})
Java:
cloudinary.url().transformation(new Transformation().width(250).height(250).crop("mpad")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 250, height: 250, crop: "mpad"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Crop("mpad")).BuildImageTag("sample.jpg")
Image mpadded to a width and height of 250 pixels

crop

Extract a region of the given width and height out of the original image. The original proportions are retained and so is the size of the graphics. You can specify the gravity parameter to select which part of the image to extract, or use fixed coordinates cropping.

For example, the uploaded jpg image named sample cropped to a width of 200 pixels, a height of 150 pixels, with northwest gravity:

Ruby:
cl_image_tag("sample.jpg", :width=>200, :height=>150, :gravity=>"north_west", :crop=>"crop")
PHP:
cl_image_tag("sample.jpg", array("width"=>200, "height"=>150, "gravity"=>"north_west", "crop"=>"crop"))
Python:
CloudinaryImage("sample.jpg").image(width=200, height=150, gravity="north_west", crop="crop")
Node.js:
cloudinary.image("sample.jpg", {width: 200, height: 150, gravity: "north_west", crop: "crop"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(150).gravity("north_west").crop("crop")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 200, height: 150, gravity: "north_west", crop: "crop"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(150).Gravity("north_west").Crop("crop")).BuildImageTag("sample.jpg")
Image cropped to 100x150 with west gravity

Fixed coordinates cropping

You can specify a region of the original image to crop by giving the x and y coordinates of the top left corner of the region together with the width and height of the region. You can also use percentage based numbers instead of the exact coordinates for x, y, w and h (e.g., 0.5 for 50%) . Use this method when you know beforehand what the correct absolute cropping coordinates are, as in when your users manually select the region to crop out of the original image.

For example, the following image shows many white sheep and one brown sheep.

Ruby:
cl_image_tag("brown_sheep.jpg")
PHP:
cl_image_tag("brown_sheep.jpg")
Python:
CloudinaryImage("brown_sheep.jpg").image()
Node.js:
cloudinary.image("brown_sheep.jpg")
Java:
cloudinary.url().imageTag("brown_sheep.jpg")
jQuery:
$.cloudinary.image("brown_sheep.jpg")
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("brown_sheep.jpg")
Original image of brown_sheep

To manipulate the picture so that only the brown sheep is visible, the image is cropped to a 300x200 region starting at the coordinate x = 355 and y = 410:

Ruby:
cl_image_tag("brown_sheep.jpg", :x=>355, :y=>410, :width=>300, :height=>200, :crop=>"crop")
PHP:
cl_image_tag("brown_sheep.jpg", array("x"=>355, "y"=>410, "width"=>300, "height"=>200, "crop"=>"crop"))
Python:
CloudinaryImage("brown_sheep.jpg").image(x=355, y=410, width=300, height=200, crop="crop")
Node.js:
cloudinary.image("brown_sheep.jpg", {x: 355, y: 410, width: 300, height: 200, crop: "crop"})
Java:
cloudinary.url().transformation(new Transformation().x(355).y(410).width(300).height(200).crop("crop")).imageTag("brown_sheep.jpg")
jQuery:
$.cloudinary.image("brown_sheep.jpg", {x: 355, y: 410, width: 300, height: 200, crop: "crop"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().X(355).Y(410).Width(300).Height(200).Crop("crop")).BuildImageTag("brown_sheep.jpg")
300x200 image generated with fixed-coordinates cropping

The image can be further manipulated with chained transformations. For example, the 300x200 cropped version above, also scaled down to 150x100:

Ruby:
cl_image_tag("brown_sheep.jpg", :transformation=>[
  {:x=>355, :y=>410, :width=>300, :height=>200, :crop=>"crop"},
  {:width=>150, :height=>100, :crop=>"scale"}
  ])
PHP:
cl_image_tag("brown_sheep.jpg", array("transformation"=>array(
  array("x"=>355, "y"=>410, "width"=>300, "height"=>200, "crop"=>"crop"),
  array("width"=>150, "height"=>100, "crop"=>"scale")
  )))
Python:
CloudinaryImage("brown_sheep.jpg").image(transformation=[
  {"x": 355, "y": 410, "width": 300, "height": 200, "crop": "crop"},
  {"width": 150, "height": 100, "crop": "scale"}
  ])
Node.js:
cloudinary.image("brown_sheep.jpg", {transformation: [
  {x: 355, y: 410, width: 300, height: 200, crop: "crop"},
  {width: 150, height: 100, crop: "scale"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .x(355).y(410).width(300).height(200).crop("crop").chain()
  .width(150).height(100).crop("scale")).imageTag("brown_sheep.jpg")
jQuery:
$.cloudinary.image("brown_sheep.jpg", {transformation: [
  {x: 355, y: 410, width: 300, height: 200, crop: "crop"},
  {width: 150, height: 100, crop: "scale"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .X(355).Y(410).Width(300).Height(200).Crop("crop").Chain()
  .Width(150).Height(100).Crop("scale")).BuildImageTag("brown_sheep.jpg")
fixed-coordinates cropped image also scaled down

thumb

The thumb cropping mode is specifically used for creating image thumbnails from either face or custom coordinates, and must always be accompanied by the gravity parameter set to one of the face detection or custom values. This cropping mode generates a thumbnail of an image with the exact given width and height dimensions and with the original proportions retained, but the resulting image might be scaled to fit in the given dimensions. You can specify the zoom parameter to determine how much to scale the resulting image within the given width and height.

For example, creating a 150x150 thumbnail with face detection, of the uploaded image called woman. Below you can see the original image as well as the face detection based thumbnail:

Original photo for face detection

Ruby:
cl_image_tag("woman.jpg", :gravity=>"face", :width=>150, :height=>150, :crop=>"thumb")
PHP:
cl_image_tag("woman.jpg", array("gravity"=>"face", "width"=>150, "height"=>150, "crop"=>"thumb"))
Python:
CloudinaryImage("woman.jpg").image(gravity="face", width=150, height=150, crop="thumb")
Node.js:
cloudinary.image("woman.jpg", {gravity: "face", width: 150, height: 150, crop: "thumb"})
Java:
cloudinary.url().transformation(new Transformation().gravity("face").width(150).height(150).crop("thumb")).imageTag("woman.jpg")
jQuery:
$.cloudinary.image("woman.jpg", {gravity: "face", width: 150, height: 150, crop: "thumb"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("face").Width(150).Height(150).Crop("thumb")).BuildImageTag("woman.jpg")
150x150 thumbnail with face detection

Imagga crop and scale

The Imagga Crop and Scale add-on can be used to smartly scale and crop your images based on automatically calculated areas of interest within each specific photo. See the Imagga Crop and Scale add-on documentation for more information.

For example, the original image:

Ruby:
cl_image_tag("family_bench.jpg")
PHP:
cl_image_tag("family_bench.jpg")
Python:
CloudinaryImage("family_bench.jpg").image()
Node.js:
cloudinary.image("family_bench.jpg")
Java:
cloudinary.url().imageTag("family_bench.jpg")
jQuery:
$.cloudinary.image("family_bench.jpg")
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("family_bench.jpg")
Original image

Image with Imagga cropping:

Ruby:
cl_image_tag("family_bench.jpg", :crop=>"imagga_crop")
PHP:
cl_image_tag("family_bench.jpg", array("crop"=>"imagga_crop"))
Python:
CloudinaryImage("family_bench.jpg").image(crop="imagga_crop")
Node.js:
cloudinary.image("family_bench.jpg", {crop: "imagga_crop"})
Java:
cloudinary.url().transformation(new Transformation().crop("imagga_crop")).imageTag("family_bench.jpg")
jQuery:
$.cloudinary.image("family_bench.jpg", {crop: "imagga_crop"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Crop("imagga_crop")).BuildImageTag("family_bench.jpg")
Image with Imagga cropping

Aspect ratio based cropping

Use the aspect_ratio parameter (ar in URLs) to resize or crop the image to a new aspect ratio. This parameter is used together with a specified crop mode (scale, fill, lfill, pad, lpad, mpad or crop), that determines how the image is adjusted to the new dimensions. This parameter can also be used when changing the dimensions of an image with only the width or height parameters (w and h in URLs) - the other dimension is then automatically updated to maintain the given aspect ratio.

The aspect_ratio parameter accepts a value in one of the following forms:

  • a:b where a signifies the relative width and b the relative height (e.g., 4:3 or 16:9).
  • a decimal value representing the ratio of the width divided by the height (e.g., 1.33 or 2.5).

Examples with the uploaded image named sample:

  • Cropped to an aspect ratio of 2.5:
    Ruby:
    cl_image_tag("sample.jpg", :aspect_ratio=>"2.5", :crop=>"crop")
    PHP:
    cl_image_tag("sample.jpg", array("aspect_ratio"=>"2.5", "crop"=>"crop"))
    Python:
    CloudinaryImage("sample.jpg").image(aspect_ratio="2.5", crop="crop")
    Node.js:
    cloudinary.image("sample.jpg", {aspect_ratio: "2.5", crop: "crop"})
    Java:
    cloudinary.url().transformation(new Transformation().aspectRatio("2.5").crop("crop")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {aspect_ratio: "2.5", crop: "crop"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().AspectRatio("2.5").Crop("crop")).BuildImageTag("sample.jpg")
    Cropped to an aspect ratio of 2.5
  • Filled to an aspect ratio of 16:9:
    Ruby:
    cl_image_tag("sample.jpg", :aspect_ratio=>"16:9", :crop=>"fill")
    PHP:
    cl_image_tag("sample.jpg", array("aspect_ratio"=>"16:9", "crop"=>"fill"))
    Python:
    CloudinaryImage("sample.jpg").image(aspect_ratio="16:9", crop="fill")
    Node.js:
    cloudinary.image("sample.jpg", {aspect_ratio: "16:9", crop: "fill"})
    Java:
    cloudinary.url().transformation(new Transformation().aspectRatio("16:9").crop("fill")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {aspect_ratio: "16:9", crop: "fill"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().AspectRatio("16:9").Crop("fill")).BuildImageTag("sample.jpg")
    Filled to aspect ratio of 16:9
  • Filled to a width of 400 pixels with an aspect ratio of 4:3:
    Ruby:
    cl_image_tag("sample.jpg", :width=>400, :aspect_ratio=>"4:3", :crop=>"fill")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>400, "aspect_ratio"=>"4:3", "crop"=>"fill"))
    Python:
    CloudinaryImage("sample.jpg").image(width=400, aspect_ratio="4:3", crop="fill")
    Node.js:
    cloudinary.image("sample.jpg", {width: 400, aspect_ratio: "4:3", crop: "fill"})
    Java:
    cloudinary.url().transformation(new Transformation().width(400).aspectRatio("4:3").crop("fill")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 400, aspect_ratio: "4:3", crop: "fill"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(400).AspectRatio("4:3").Crop("fill")).BuildImageTag("sample.jpg")
    Filled to a width of 400 pixels with an aspect ratio of 4:3

Control gravity

The gravity parameter (g in URLs) is used to specify a location in the image that is used as the focus for another transformation:

  • For certain cropping modes, gravity specifies which part of the original image to focus on (include) when the resulting image is smaller than than the original or the proportions do not match.
  • For placing underlays, overlays or text captions, gravity specifies where to place them in relation to the original image.

The basic gravity value is specified by giving a compass direction to focus on: north_east, north, north_west, west, south_west, south, south_east, east, or center (the default value). The compass direction represents a location in the image, for example, north_east represents the top right corner.

For example, the uploaded jpg image named sample filled to a width and height of 250 pixels while retaining the aspect ratio:

  • Original image:
    Ruby:
    cl_image_tag("sample.jpg")
    PHP:
    cl_image_tag("sample.jpg")
    Python:
    CloudinaryImage("sample.jpg").image()
    Node.js:
    cloudinary.image("sample.jpg")
    Java:
    cloudinary.url().imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg")
    .Net:
    cloudinary.Api.UrlImgUp.BuildImageTag("sample.jpg")
    Original image
  • With gravity set to north:
    Ruby:
    cl_image_tag("sample.jpg", :width=>250, :height=>250, :gravity=>"north", :crop=>"fill")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "gravity"=>"north", "crop"=>"fill"))
    Python:
    CloudinaryImage("sample.jpg").image(width=250, height=250, gravity="north", crop="fill")
    Node.js:
    cloudinary.image("sample.jpg", {width: 250, height: 250, gravity: "north", crop: "fill"})
    Java:
    cloudinary.url().transformation(new Transformation().width(250).height(250).gravity("north").crop("fill")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 250, height: 250, gravity: "north", crop: "fill"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Gravity("north").Crop("fill")).BuildImageTag("sample.jpg")
    Image filled to a width and height of 250 pixels with north gravity
  • With gravity set to south_east:
    Ruby:
    cl_image_tag("sample.jpg", :width=>250, :height=>250, :gravity=>"south_east", :crop=>"fill")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>250, "height"=>250, "gravity"=>"south_east", "crop"=>"fill"))
    Python:
    CloudinaryImage("sample.jpg").image(width=250, height=250, gravity="south_east", crop="fill")
    Node.js:
    cloudinary.image("sample.jpg", {width: 250, height: 250, gravity: "south_east", crop: "fill"})
    Java:
    cloudinary.url().transformation(new Transformation().width(250).height(250).gravity("south_east").crop("fill")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 250, height: 250, gravity: "south_east", crop: "fill"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(250).Gravity("south_east").Crop("fill")).BuildImageTag("sample.jpg")
    Image filled to a width and height of 250 pixels with north gravity

More advanced gravity parameters include:

  • xy_center - Set the center of gravity to the given x & y coordinates.
  • face - Automatically detect the largest face in an image and make it the focus of the transformation. Any previously specified face coordinates (during upload, with the Admin API, or via the Management Console) override the automatically detected faces and are used instead. Defaults to north gravity if no faces are detected or previously specified.
  • faces - Same as face gravity, but detects all the faces in an image and makes them the focus of the transformation. Any previously specified face coordinates (during upload, with the Admin API, or via the Management Console) override the automatically detected faces and are used instead. Defaults to north gravity if no faces are detected or previously specified.
  • face:center - Same as face gravity, but defaults to center gravity if no face is detected.
  • faces:center - Same as faces gravity, but defaults to center gravity if no face is detected.
  • adv_face - Automatically detect the largest face in an image with the Advanced Facial Attribute Detection add-on and make it the focus of the transformation.
  • adv_faces - Automatically detect all faces in an image with the Advanced Facial Attribute Detection add-on and make them the focus of the transformation.
  • adv_eyes - Automatically detect all eyes in an image with the Advanced Facial Attribute Detection add-on and make them the focus of the transformation.
  • custom - Use custom coordinates that were previously specified (e.g., as part of the image upload method) and make them the focus of the transformation. Defaults to 'center' gravity if no custom coordinates have been specified.
  • custom:face - Same as custom gravity, but defaults to face gravity if no custom coordinates have been specified.
  • custom:faces - Same as custom gravity, but defaults to faces gravity if no custom coordinates have been specified.
  • custom:adv_face - Same as custom gravity, but defaults to adv_face gravity if no custom coordinates have been specified.
  • custom:adv_faces - Same as custom gravity, but defaults to adv_faces gravity if no custom coordinates have been specified.

Note: The fallback (default) values are only relevant when setting gravity for cropping modes and not when setting gravity for placing overlays. For example, if gravity is set to 'face' for placing an overlay, and no face is detected in the image, then the overlay is ignored.

Automatic cropping

Cloudinary's intelligent cropping capabilities ensure that the most interesting areas of each image are included in the resulting derived image, not only for photos with faces, but for any content type. Each image is analyzed individually to find the optimal region to focus on while cropping, and automatically detected faces (or other elements) are given higher priority while analyzing the image content (note that any custom coordinates defined will override the detection algorithm).

The Cloudinary content-aware cropping algorithm uses a combination of heuristics to automatically detect the region of interest in every image and then crop them on the fly. Automatic cropping is supported by setting the gravity transformation parameter to auto (g_auto in URLs):

  • g_auto1 - The default mode that gives higher priority to automatically detected faces (the same as g_auto:faces).
  • g_auto:[focal_gravity]1 - (e.g., g_auto:adv_face). Specific focal gravities can be specified in order to give higher priority to other auto detected regions rather than the default of giving priority to detected faces. Supported options for focal_gravity: adv_face, adv_faces, adv_eyes, body, face, and faces (default).
  • g_auto:no_faces1 - the algorithm will process the image without giving higher priority to any detected elements (e.g., auto detected faces).
  • g_auto:custom_no_override - Don't override the algorithm with the custom coordinates but give higher priority to the custom coordinates when determining the region of interest.
  • g_auto:none - Perform analysis of the image content without giving precedence to custom coordinates or higher priority to any detected element.
  • g_auto:[level]1 - (Only relevant for the thumb cropping mode). The level of aggressiveness of the cropping algorithm between 0 and 100, where 100 tries to keep more of the original image, and 0 crops more aggressively and then zooms in to image. e.g., g_auto:50, g_auto:adv_faces:0. The default is 100.

1 If custom coordinates have been specified for an image (using the Upload API or the Management Console), the cropping will be done according to them, taking the custom coordinates as-is and overriding the detection algorithm (the same as g_custom). This applies to all the g_auto options above except for g_auto:custom_no_override and g_auto:none.

Automatic cropping is supported for the fill, lfill, thumb and crop modes.

Automatic cropping with the fill mode

Keeping the most of the original image according to the requested dimensions of the derived image. Ensuring that as much as possible of the most interesting regions of the original image is included in the resulting image.

Example of portrait aspect ratio cropping, regular vs. automatic:

Original image Original Regular image thumbnail w_200,h_300,c_fill,g_center
Regular fill
Automatic image thumbnail with fill w_200,h_300,c_fill,g_auto
Automatic fill

Ruby:
cl_image_tag("basketball_in_net.jpg", :width=>200, :height=>300, :gravity=>"auto", :crop=>"fill")
PHP:
cl_image_tag("basketball_in_net.jpg", array("width"=>200, "height"=>300, "gravity"=>"auto", "crop"=>"fill"))
Python:
CloudinaryImage("basketball_in_net.jpg").image(width=200, height=300, gravity="auto", crop="fill")
Node.js:
cloudinary.image("basketball_in_net.jpg", {width: 200, height: 300, gravity: "auto", crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(300).gravity("auto").crop("fill")).imageTag("basketball_in_net.jpg")
jQuery:
$.cloudinary.image("basketball_in_net.jpg", {width: 200, height: 300, gravity: "auto", crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(300).Gravity("auto").Crop("fill")).BuildImageTag("basketball_in_net.jpg")

Example of square aspect ratio cropping, regular vs. automatic:

Original image Original Regular image thumbnail w_200,h_200,c_fill,g_center
Regular fill
Automatic image thumbnail with fill w_200,h_200,c_fill,g_auto
Automatic fill

Ruby:
cl_image_tag("face_left.jpg", :width=>200, :height=>200, :gravity=>"auto", :crop=>"fill")
PHP:
cl_image_tag("face_left.jpg", array("width"=>200, "height"=>200, "gravity"=>"auto", "crop"=>"fill"))
Python:
CloudinaryImage("face_left.jpg").image(width=200, height=200, gravity="auto", crop="fill")
Node.js:
cloudinary.image("face_left.jpg", {width: 200, height: 200, gravity: "auto", crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(200).gravity("auto").crop("fill")).imageTag("face_left.jpg")
jQuery:
$.cloudinary.image("face_left.jpg", {width: 200, height: 200, gravity: "auto", crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(200).Gravity("auto").Crop("fill")).BuildImageTag("face_left.jpg")

Automatic cropping with the lfill mode

Same as the fill mode, but only if the original image is larger than the given limit (width and height). This mode doesn't scale up the image if your requested dimensions are bigger than the original image's.

Automatic cropping with the thumb mode

Makes possible more aggressive cropping than the fill mode. This mode attempts to further zoom in and crop out less interesting image regions when relevant in order to include the most interesting objects in the resulting derived image. The automatic cropping algorithm decides whether and how aggressively to zoom-in and crop according to the content and cropping ratio of each image individually. A numerical value between 0 and 100 can be added to the g_auto parameter in order to advise the algorithm regarding the desired aggressiveness level (e.g., g_auto:0 for the most aggressive thumb cropping).

Example of a square thumbnail, regular vs. automatic cropping:

Original Original Regular image thumbnail c_thumb,g_center
Regular thumbnail
Automatic image thumbnail c_thumb,g_auto
Automatic thumbnail
Automatic image thumbnail with the most aggressive cropping c_thumb,g_auto:0
Automatic thumbnail -
most aggressive

Ruby:
cl_image_tag("sunset_shoes.jpg", :width=>150, :height=>150, :gravity=>"auto:0", :crop=>"thumb")
PHP:
cl_image_tag("sunset_shoes.jpg", array("width"=>150, "height"=>150, "gravity"=>"auto:0", "crop"=>"thumb"))
Python:
CloudinaryImage("sunset_shoes.jpg").image(width=150, height=150, gravity="auto:0", crop="thumb")
Node.js:
cloudinary.image("sunset_shoes.jpg", {width: 150, height: 150, gravity: "auto:0", crop: "thumb"})
Java:
cloudinary.url().transformation(new Transformation().width(150).height(150).gravity("auto:0").crop("thumb")).imageTag("sunset_shoes.jpg")
jQuery:
$.cloudinary.image("sunset_shoes.jpg", {width: 150, height: 150, gravity: "auto:0", crop: "thumb"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(150).Gravity("auto:0").Crop("thumb")).BuildImageTag("sunset_shoes.jpg")

Automatic cropping with the crop mode

Crop a region of exactly the given width and height out of the original image while automatically focusing on the most interesting region of the original image that fits within the required dimensions. The portion of the interesting area depends on the resolution of the original image. The crop mode is less useful than the fill, lfill, and thumb modes, as it is only practical to use when both the dimensions of the original image and the size of the interesting region are already known.

Example of a square crop, regular vs. auto cropping:

Original image Original Regular image thumbnail c_crop,g_center
Regular crop
Automatic image thumbnail with crop c_crop,g_auto
Automatic crop

Ruby:
cl_image_tag("fat_cat.jpg", :width=>200, :height=>200, :gravity=>"auto", :crop=>"crop")
PHP:
cl_image_tag("fat_cat.jpg", array("width"=>200, "height"=>200, "gravity"=>"auto", "crop"=>"crop"))
Python:
CloudinaryImage("fat_cat.jpg").image(width=200, height=200, gravity="auto", crop="crop")
Node.js:
cloudinary.image("fat_cat.jpg", {width: 200, height: 200, gravity: "auto", crop: "crop"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(200).gravity("auto").crop("crop")).imageTag("fat_cat.jpg")
jQuery:
$.cloudinary.image("fat_cat.jpg", {width: 200, height: 200, gravity: "auto", crop: "crop"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(200).Gravity("auto").Crop("crop")).BuildImageTag("fat_cat.jpg")

Face detection based transformations

Cloudinary provides face detection algorithms for automatically applying transformations according to the detected faces within an image. This section consists of the following topics:

Face detection based cropping

Cloudinary supports built-in face detection capabilities that allow you to intelligently crop your images. To automatically crop an image so that the detected face(s) is used as the center of the derived picture, set the gravity parameter to one of the following values:

  • face - the region of the image that includes the single largest face (g_face for URLs).
  • faces - the region of the image that includes all the faces detected (g_faces for URLs).

For example, the image below of a nice woman with a Blue Morpho butterfly was uploaded to Cloudinary:

Ruby:
cl_image_tag("butterfly.jpg")
PHP:
cl_image_tag("butterfly.jpg")
Python:
CloudinaryImage("butterfly.jpg").image()
Node.js:
cloudinary.image("butterfly.jpg")
Java:
cloudinary.url().imageTag("butterfly.jpg")
jQuery:
$.cloudinary.image("butterfly.jpg")
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("butterfly.jpg")
butterfly.jpg uploaded to Cloudinary

To create a 200x200 version with the fill cropping mode to keep as much as possible of the original image, and using the default center gravity without face detection (for comparison):

Ruby:
cl_image_tag("butterfly.jpg", :width=>200, :height=>200, :crop=>"fill")
PHP:
cl_image_tag("butterfly.jpg", array("width"=>200, "height"=>200, "crop"=>"fill"))
Python:
CloudinaryImage("butterfly.jpg").image(width=200, height=200, crop="fill")
Node.js:
cloudinary.image("butterfly.jpg", {width: 200, height: 200, crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(200).crop("fill")).imageTag("butterfly.jpg")
jQuery:
$.cloudinary.image("butterfly.jpg", {width: 200, height: 200, crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(200).Crop("fill")).BuildImageTag("butterfly.jpg")
200x200 filled without face detection

Now adding the face gravity parameter to correctly fill the requested dimensions:

Ruby:
cl_image_tag("butterfly.jpg", :width=>200, :height=>200, :gravity=>"face", :crop=>"fill")
PHP:
cl_image_tag("butterfly.jpg", array("width"=>200, "height"=>200, "gravity"=>"face", "crop"=>"fill"))
Python:
CloudinaryImage("butterfly.jpg").image(width=200, height=200, gravity="face", crop="fill")
Node.js:
cloudinary.image("butterfly.jpg", {width: 200, height: 200, gravity: "face", crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(200).gravity("face").crop("fill")).imageTag("butterfly.jpg")
jQuery:
$.cloudinary.image("butterfly.jpg", {width: 200, height: 200, gravity: "face", crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(200).Gravity("face").Crop("fill")).BuildImageTag("butterfly.jpg")
200x200 filled with face detection

In order to create a 200x200 thumbnail focused on the face of the woman, simply select the thumb crop mode and face gravity:

Ruby:
cl_image_tag("butterfly.jpg", :width=>200, :height=>200, :gravity=>"face", :crop=>"thumb")
PHP:
cl_image_tag("butterfly.jpg", array("width"=>200, "height"=>200, "gravity"=>"face", "crop"=>"thumb"))
Python:
CloudinaryImage("butterfly.jpg").image(width=200, height=200, gravity="face", crop="thumb")
Node.js:
cloudinary.image("butterfly.jpg", {width: 200, height: 200, gravity: "face", crop: "thumb"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(200).gravity("face").crop("thumb")).imageTag("butterfly.jpg")
jQuery:
$.cloudinary.image("butterfly.jpg", {width: 200, height: 200, gravity: "face", crop: "thumb"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(200).Gravity("face").Crop("thumb")).BuildImageTag("butterfly.jpg")
90x90 thumb focused on the face of the woman

You can also automatically crop to the region defined by face detection without resizing the original image. The following example uses the crop mode together with face gravity for cropping the original image to the face of the woman:

Ruby:
cl_image_tag("butterfly.jpg", :gravity=>"face", :crop=>"crop")
PHP:
cl_image_tag("butterfly.jpg", array("gravity"=>"face", "crop"=>"crop"))
Python:
CloudinaryImage("butterfly.jpg").image(gravity="face", crop="crop")
Node.js:
cloudinary.image("butterfly.jpg", {gravity: "face", crop: "crop"})
Java:
cloudinary.url().transformation(new Transformation().gravity("face").crop("crop")).imageTag("butterfly.jpg")
jQuery:
$.cloudinary.image("butterfly.jpg", {gravity: "face", crop: "crop"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("face").Crop("crop")).BuildImageTag("butterfly.jpg")
90x90 cropped to the face of the woman

For examples with multiple faces, the following image, showing a nice couple, was uploaded to Cloudinary:

Ruby:
cl_image_tag("couple.jpg")
PHP:
cl_image_tag("couple.jpg")
Python:
CloudinaryImage("couple.jpg").image()
Node.js:
cloudinary.image("couple.jpg")
Java:
cloudinary.url().imageTag("couple.jpg")
jQuery:
$.cloudinary.image("couple.jpg")
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("couple.jpg")
couple.jpg uploaded to Cloudinary

You can specify the thumb crop mode and face gravity to create a 150x150 thumbnail centered on the face of only the biggest face in the image:

Ruby:
cl_image_tag("couple.jpg", :width=>150, :height=>150, :gravity=>"face", :crop=>"thumb")
PHP:
cl_image_tag("couple.jpg", array("width"=>150, "height"=>150, "gravity"=>"face", "crop"=>"thumb"))
Python:
CloudinaryImage("couple.jpg").image(width=150, height=150, gravity="face", crop="thumb")
Node.js:
cloudinary.image("couple.jpg", {width: 150, height: 150, gravity: "face", crop: "thumb"})
Java:
cloudinary.url().transformation(new Transformation().width(150).height(150).gravity("face").crop("thumb")).imageTag("couple.jpg")
jQuery:
$.cloudinary.image("couple.jpg", {width: 150, height: 150, gravity: "face", crop: "thumb"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(150).Gravity("face").Crop("thumb")).BuildImageTag("couple.jpg")
150x150 thumb focused on the biggest face in the image

In order to create a thumbnail focusing on the faces of both of them, simply specify faces as the gravity:

Ruby:
cl_image_tag("couple.jpg", :width=>115, :height=>135, :gravity=>"faces", :crop=>"thumb")
PHP:
cl_image_tag("couple.jpg", array("width"=>115, "height"=>135, "gravity"=>"faces", "crop"=>"thumb"))
Python:
CloudinaryImage("couple.jpg").image(width=115, height=135, gravity="faces", crop="thumb")
Node.js:
cloudinary.image("couple.jpg", {width: 115, height: 135, gravity: "faces", crop: "thumb"})
Java:
cloudinary.url().transformation(new Transformation().width(115).height(135).gravity("faces").crop("thumb")).imageTag("couple.jpg")
jQuery:
$.cloudinary.image("couple.jpg", {width: 115, height: 135, gravity: "faces", crop: "thumb"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(115).Height(135).Gravity("faces").Crop("thumb")).BuildImageTag("couple.jpg")
thumb focused on all faces in the image

You can also use the fill cropping mode together with faces gravity to correctly fill an image with your desired dimensions:

Ruby:
cl_image_tag("couple.jpg", :width=>100, :height=>150, :gravity=>"faces", :crop=>"fill")
PHP:
cl_image_tag("couple.jpg", array("width"=>100, "height"=>150, "gravity"=>"faces", "crop"=>"fill"))
Python:
CloudinaryImage("couple.jpg").image(width=100, height=150, gravity="faces", crop="fill")
Node.js:
cloudinary.image("couple.jpg", {width: 100, height: 150, gravity: "faces", crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(100).height(150).gravity("faces").crop("fill")).imageTag("couple.jpg")
jQuery:
$.cloudinary.image("couple.jpg", {width: 100, height: 150, gravity: "faces", crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(100).Height(150).Gravity("faces").Crop("fill")).BuildImageTag("couple.jpg")
60x150 filled to focus on all faces in the image

Position overlays on detected faces

To automatically position an overlay over the detected face(s) in an image, set the gravity parameter to one of the following values:

  • face - places an overlay over the single largest face in the image (g_face for URLs).
  • faces - places an overlay over each of the faces in the image (g_faces for URLs).

For example, adding an overlay of the golden_star image over both of the faces detected in the young_couples image, where each star is resized to the same width as the detected face with the region_relative flag:

Ruby:
cl_image_tag("young_couple.jpg", :overlay=>"golden_star", :gravity=>"faces", :width=>1.0, :flags=>"region_relative")
PHP:
cl_image_tag("young_couple.jpg", array("overlay"=>"golden_star", "gravity"=>"faces", "width"=>1.0, "flags"=>"region_relative"))
Python:
CloudinaryImage("young_couple.jpg").image(overlay="golden_star", gravity="faces", width=1.0, flags="region_relative")
Node.js:
cloudinary.image("young_couple.jpg", {overlay: "golden_star", gravity: "faces", width: 1.0, flags: "region_relative"})
Java:
cloudinary.url().transformation(new Transformation().overlay("golden_star").gravity("faces").width(1.0).flags("region_relative")).imageTag("young_couple.jpg")
jQuery:
$.cloudinary.image("young_couple.jpg", {overlay: "golden_star", gravity: "faces", width: 1.0, flags: "region_relative"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("golden_star").Gravity("faces").Width(1.0).Flags("region_relative")).BuildImageTag("young_couple.jpg")
Image with overlay placed over faces

Note: When gravity is set to one of the facial detection values and no face is detected in the image, then no overlay is placed at all.

Effects with face detection

To apply a blur or pixelation effect to the automatically detected faces in an image, use the effect parameter and set it to one of the following values:

  • blur_faces - Automatically blur all detected faces in the image: the strength of the blur effect is determined by an optional extra value (Range: 1 to 2000, Default: 500). For example, e_blur_faces:100 uses a mild blur effect with a strength of 100.
  • pixelate_faces - Automatically pixelate all detected faces in the image. The width of the pixelation squares is determined by an optional extra value (Range: 1 to 200, Default: 5). For example, e_pixelate_faces:3 uses pixelation squares 3 pixels wide.

For example, to automatically pixelate both of the faces detected in the young_couples image with pixelation squares 9 pixels wide:

Ruby:
cl_image_tag("young_couple.jpg", :effect=>"pixelate_faces:9")
PHP:
cl_image_tag("young_couple.jpg", array("effect"=>"pixelate_faces:9"))
Python:
CloudinaryImage("young_couple.jpg").image(effect="pixelate_faces:9")
Node.js:
cloudinary.image("young_couple.jpg", {effect: "pixelate_faces:9"})
Java:
cloudinary.url().transformation(new Transformation().effect("pixelate_faces:9")).imageTag("young_couple.jpg")
jQuery:
$.cloudinary.image("young_couple.jpg", {effect: "pixelate_faces:9"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("pixelate_faces:9")).BuildImageTag("young_couple.jpg")
Image with faces blurred

Advanced facial attributes detection

With the Advanced Facial Attributes Detection add-on, you can extend the Cloudinary built-in features that involve semantic photo data extraction, image cropping and the positioning of image overlays. When using the add-on, your images are further processed and additional advanced face attributes are automatically extracted. Cloudinary can then use these additional details to smartly crop, position, rotate and overlay images according to the position of the detected faces or eyes.

The advanced facial detection is applied by setting the gravity parameter to one of the following values:

  • adv_face - detects the single largest face in the image (g_adv_face for URLs).
  • adv_faces - detects all of the faces in the image (g_adv_faces for URLs).
  • adv_eyes - detects all the pairs of eyes in the image (g_adv_eyes for URLs).

For example, to automatically overlay the image glasses over the detected eyes in the couples image. The glasses are resized to 170% the width of the detected eyes by adding the region_relative flag:

Ruby:
cl_image_tag("coupled.jpg", :flags=>"region_relative", :gravity=>"adv_eyes", :overlay=>"glasses", :width=>1.7)
PHP:
cl_image_tag("coupled.jpg", array("flags"=>"region_relative", "gravity"=>"adv_eyes", "overlay"=>"glasses", "width"=>1.7))
Python:
CloudinaryImage("coupled.jpg").image(flags="region_relative", gravity="adv_eyes", overlay="glasses", width=1.7)
Node.js:
cloudinary.image("coupled.jpg", {flags: "region_relative", gravity: "adv_eyes", overlay: "glasses", width: 1.7})
Java:
cloudinary.url().transformation(new Transformation().flags("region_relative").gravity("adv_eyes").overlay("glasses").width(1.7)).imageTag("coupled.jpg")
jQuery:
$.cloudinary.image("coupled.jpg", {flags: "region_relative", gravity: "adv_eyes", overlay: "glasses", width: 1.7})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Flags("region_relative").Gravity("adv_eyes").Overlay("glasses").Width(1.7)).BuildImageTag("coupled.jpg")
Automatically placed glasses on detected faces

See the Advanced Facial Attributes Detection documentation for more information and examples on using the add-on.

Zoom level

When using either the crop or thumb cropping modes and setting the gravity parameter to one of the face detection values, the resulting image is delivered at a default zoom level. To control how much of the original image surrounding the face to keep, use the zoom parameter (z for URLs). This parameter accepts a decimal value that sets the new zoom level as a multiplier of the default zoom setting: a value less than 1.0 zooms out and a value greater than 1.0 zooms in. For example, z_0.5 halves the default zoom to 50% and zooms out to include more of the background around the face, while z_2.0 doubles the default zoom to 200% and zooms in to include less of the background around the face.

Examples with the uploaded image called woman:

  • Original image (scaled down):
    Ruby:
    cl_image_tag("woman.jpg")
    PHP:
    cl_image_tag("woman.jpg")
    Python:
    CloudinaryImage("woman.jpg").image()
    Node.js:
    cloudinary.image("woman.jpg")
    Java:
    cloudinary.url().imageTag("woman.jpg")
    jQuery:
    $.cloudinary.image("woman.jpg")
    .Net:
    cloudinary.Api.UrlImgUp.BuildImageTag("woman.jpg")
    Original image
  • Cropped with face detection and default zoom:
    Ruby:
    cl_image_tag("woman.jpg", :gravity=>"face", :crop=>"crop")
    PHP:
    cl_image_tag("woman.jpg", array("gravity"=>"face", "crop"=>"crop"))
    Python:
    CloudinaryImage("woman.jpg").image(gravity="face", crop="crop")
    Node.js:
    cloudinary.image("woman.jpg", {gravity: "face", crop: "crop"})
    Java:
    cloudinary.url().transformation(new Transformation().gravity("face").crop("crop")).imageTag("woman.jpg")
    jQuery:
    $.cloudinary.image("woman.jpg", {gravity: "face", crop: "crop"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("face").Crop("crop")).BuildImageTag("woman.jpg")
    Cropped with face detection and default zoom
  • Cropped with face detection and zoom set to 130%:
    Ruby:
    cl_image_tag("woman.jpg", :gravity=>"face", :zoom=>1.3, :crop=>"crop")
    PHP:
    cl_image_tag("woman.jpg", array("gravity"=>"face", "zoom"=>1.3, "crop"=>"crop"))
    Python:
    CloudinaryImage("woman.jpg").image(gravity="face", zoom=1.3, crop="crop")
    Node.js:
    cloudinary.image("woman.jpg", {gravity: "face", zoom: 1.3, crop: "crop"})
    Java:
    cloudinary.url().transformation(new Transformation().gravity("face").zoom(1.3).crop("crop")).imageTag("woman.jpg")
    jQuery:
    $.cloudinary.image("woman.jpg", {gravity: "face", zoom: 1.3, crop: "crop"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("face").Zoom(1.3).Crop("crop")).BuildImageTag("woman.jpg")
    Cropped with face detection and zoom set to 120%
  • 150x150 thumbnail with face detection and default zoom:
    Ruby:
    cl_image_tag("woman.jpg", :gravity=>"face", :width=>150, :height=>150, :crop=>"thumb")
    PHP:
    cl_image_tag("woman.jpg", array("gravity"=>"face", "width"=>150, "height"=>150, "crop"=>"thumb"))
    Python:
    CloudinaryImage("woman.jpg").image(gravity="face", width=150, height=150, crop="thumb")
    Node.js:
    cloudinary.image("woman.jpg", {gravity: "face", width: 150, height: 150, crop: "thumb"})
    Java:
    cloudinary.url().transformation(new Transformation().gravity("face").width(150).height(150).crop("thumb")).imageTag("woman.jpg")
    jQuery:
    $.cloudinary.image("woman.jpg", {gravity: "face", width: 150, height: 150, crop: "thumb"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("face").Width(150).Height(150).Crop("thumb")).BuildImageTag("woman.jpg")
    150x150 thumbnail with face detection and default zoom
  • 150x150 thumbnail with face detection and zoom set to 70%:
    Ruby:
    cl_image_tag("woman.jpg", :gravity=>"face", :width=>150, :height=>150, :zoom=>0.7, :crop=>"thumb")
    PHP:
    cl_image_tag("woman.jpg", array("gravity"=>"face", "width"=>150, "height"=>150, "zoom"=>0.7, "crop"=>"thumb"))
    Python:
    CloudinaryImage("woman.jpg").image(gravity="face", width=150, height=150, zoom=0.7, crop="thumb")
    Node.js:
    cloudinary.image("woman.jpg", {gravity: "face", width: 150, height: 150, zoom: 0.7, crop: "thumb"})
    Java:
    cloudinary.url().transformation(new Transformation().gravity("face").width(150).height(150).zoom(0.7).crop("thumb")).imageTag("woman.jpg")
    jQuery:
    $.cloudinary.image("woman.jpg", {gravity: "face", width: 150, height: 150, zoom: 0.7, crop: "thumb"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Gravity("face").Width(150).Height(150).Zoom(0.7).Crop("thumb")).BuildImageTag("woman.jpg")
    150x150 thumbnail with face detection and default zoom

For more examples on using the zoom parameter see the article on How to control the zoom level with automatic face detection based image cropping.

Image format conversion

Images can be uploaded to Cloudinary in various formats, and you can easily convert these images to other formats for displaying in your web site or application. Examples of situations where you might want to change the delivered image format:

  • Delivering JPEGs for photos that you want to load quickly (or WebP if your users are on a Chrome browser or on a mobile app you control).
  • Delivering a GIF if the image contains a drawing with only a few colors.
  • Delivering a PNG (24 bit) for high quality illustrations with a transparent background.

You can dynamically convert images to your desired format. Cloudinary currently supports the following image formats:

Format Extensions Supported for Upload Supported for Transformations
JPEG (Joint Photographic Experts Group) .jpg, .jpe, .jpeg Yes Yes
JPEG 2000 (JPEG 2000) .jpc, .jp2, .j2k Yes Yes
JPEG XR (JPEG eXtended Range) .wdp, .jxr, .hdp Yes Yes
PNG (Portable Network Graphics) .png Yes Yes
GIF (Graphics Interchange Format) .gif Yes Yes
WebP .webp Yes Yes
BMP (BitMaP image format) .bmp Yes Yes
TIFF (Tagged Image File Format) .tif, .tiff Yes Yes
ICO (ICOn image format) .ico Yes Yes
PDF (Portable Document Format) .pdf Yes Yes
EPS (Encapsulated PostScript) .ps, .ept, .eps, .eps3 Yes No
PSD (PhotoShop Document) .psd Yes No
SVG (Scalable Vector Graphics) .svg Yes No
AI (Adobe Illustrator) .ai Yes No
DjVu .djvu Yes No
FLIF (Free Lossless Image Format) .flif Yes No
TARGA (Truevision TGA) .tga Yes No

To deliver images in a different format simply specify the new format as the file extension of the delivery URL. When using our SDKs you can either specify the new format as an extension to the resource name or use the format parameter.

For example, to display a GIF version of the uploaded sample JPEG file:

Ruby:
cl_image_tag("sample.gif")
PHP:
cl_image_tag("sample.gif")
Python:
CloudinaryImage("sample.gif").image()
Node.js:
cloudinary.image("sample.gif")
Java:
cloudinary.url().imageTag("sample.gif")
jQuery:
$.cloudinary.image("sample.gif")
.Net:
cloudinary.Api.UrlImgUp.BuildImageTag("sample.gif")
Image converted to gif

You can easily combine other image transformations with format conversion. Just make sure the format you use is supported for transformations, as per the table above. For example, to deliver a scaled down 150x100 GIF version of the sample image:

Ruby:
cl_image_tag("sample.gif", :width=>150, :height=>100, :crop=>"scale")
PHP:
cl_image_tag("sample.gif", array("width"=>150, "height"=>100, "crop"=>"scale"))
Python:
CloudinaryImage("sample.gif").image(width=150, height=100, crop="scale")
Node.js:
cloudinary.image("sample.gif", {width: 150, height: 100, crop: "scale"})
Java:
cloudinary.url().transformation(new Transformation().width(150).height(100).crop("scale")).imageTag("sample.gif")
jQuery:
$.cloudinary.image("sample.gif", {width: 150, height: 100, crop: "scale"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(100).Crop("scale")).BuildImageTag("sample.gif")
Image scaled down to 150x100 gif

Note: If the file extension is omitted from the delivery URL then the file is delivered in the originally uploaded format.

Fetch format

Another option for changing the format is to explicitly call the fetch_format parameter (f in URLs). This can be useful in situations where you cannot change the file extension, for example, when fetching remote images that already have a different file extension (format) as part of their URLs.

For example, to fetch a remote image from Wikimedia in JPEG format, and deliver the image in PNG format (also scaled down to a width of 400 pixels):

Ruby:
cl_image_tag("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg", :width=>400, :format=>"png", :type=>"fetch")
PHP:
cl_image_tag("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg", array("width"=>400, "format"=>"png", "type"=>"fetch"))
Python:
CloudinaryImage("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg").image(width=400, format="png", type="fetch")
Node.js:
cloudinary.image("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg", {width: 400, format: "png", type: "fetch"})
Java:
cloudinary.url().transformation(new Transformation().width(400)).format("png").type("fetch").imageTag("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg")
jQuery:
$.cloudinary.image("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg", {width: 400, format: "png", type: "fetch"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(400)).Format("png").Type("fetch").BuildImageTag("http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg")
Jennifer Lawrence fetched from Wikimedia and delivered as a PNG

Automatic format selection

You can also use the fetch_format feature to save bandwidth and optimize delivery time by automatically delivering images as WebP to Chrome browsers or JPEG-XR to Internet Explorer browsers. Simply set the value to auto and the best format will be delivered to the supported browser. If a browser does not support either of these formats then the image is delivered in the format specified by the file extension.

For example, the uploaded jpg image named sample scaled down to a width of 500 pixels and delivered as WebP to Chrome browsers (22.4 KB), JPEG-XR to Internet Explorer browsers (48 KB), or as a regular JPEG (57.5 KB) to browsers that support neither format:

Ruby:
cl_image_tag("sample.jpg", :width=>500, :fetch_format=>:auto)
PHP:
cl_image_tag("sample.jpg", array("width"=>500, "fetch_format"=>"auto"))
Python:
CloudinaryImage("sample.jpg").image(width=500, fetch_format="auto")
Node.js:
cloudinary.image("sample.jpg", {width: 500, fetch_format: "auto"})
Java:
cloudinary.url().transformation(new Transformation().width(500).fetchFormat("auto")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 500, fetch_format: "auto"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(500).FetchFormat("auto")).BuildImageTag("sample.jpg")
Image delivered with f_auto

Notes:

  • When automatic format (f_auto) is used together with automatic quality (q_auto), the PNG format may be selected when the automatic quality algorithm decides that it better fits the specific image. This allows delivering better looking and economical image files.
  • When f_auto is used together with q_auto for JPEG images and the automatic quality algorithm decides that no chroma subsampling should be performed, the JPEG format is selected instead of WebP. This behavior is needed because the lossy WebP format always performs chroma subsampling, which might result in a lower visual quality for some images.
  • Setting the any_format flag together with automatic quality (q_auto,fl_any_format) but without setting f_auto, will also allow switching to PNG8 encoding if the quality algorithm decides that it's more efficient.
  • To ensure that a PNG will always be delivered for images that include a transparent element, add the preserve_transparency flag together with f_auto.

Adjusting image quality

Control the visual quality and compression level of JPEG, JPEG 2000, JPEG XR, WebP and GIF images with the quality parameter (q in URLs). This parameter represents the compression level to apply to an image as a value between 1 (smallest file size possible) and 100 (best visual quality). Reducing the quality is a tradeoff between visual quality and file size: the lower the quality value, the more the file is compressed to a smaller file size, the more data is lost in the process, and the result is a loss of visual quality. The loss of visual quality is barely noticeable to the human eye at the higher quality levels, and final visual quality also depends on other factors such as the size of the image and the resolution of the user's monitor or mobile screen.

For example, reducing the quality of the uploaded JPEG image named sample to 60 results in a file size of 73 KB compared to the original file size of 245 KB with a barely noticeable reduction in visual quality:

Ruby:
cl_image_tag("sample.jpg", :quality=>60)
PHP:
cl_image_tag("sample.jpg", array("quality"=>60))
Python:
CloudinaryImage("sample.jpg").image(quality=60)
Node.js:
cloudinary.image("sample.jpg", {quality: 60})
Java:
cloudinary.url().transformation(new Transformation().quality(60)).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {quality: 60})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Quality(60)).BuildImageTag("sample.jpg")
Image with quality set to 60

The quality parameter is also automatically applied when delivering images with any other transformation applied. That is, unless the original uploaded image is requested, then a default quality* value of 80 is also automatically applied to the transformed image.

* The default values were updated in June 2016. Cloudinary customers that opened an account before that date will initially have the following default values for each format if the quality parameter is not specified: JPEG: 90, WebP: 75, JPEG XR and JPEG 2000: 80

The default quality setting for your Cloudinary account can be customized via the Settings page in the Management Console. We recommend setting the default value to one of the automatic quality values.

Notes:

  1. Images in the WebP format are lossless when specifying a quality of 100, and lossy when specifying a quality less than 100. See the How to support WebP images, save bandwidth and improve user experience article for more information on the WebP format.
  2. Images in the WebP format are lossless if the quality isn't specified and the original image's format is lossless (e.g., PNG).
  3. Animated GIFs ignore the quality setting unless the lossy flag is added. See the Lossy compression for optimizing animated GIFs article for more information.
  4. The JPEGmini add-on automatically applies the best compression possible to JPEG images while maintaining a high visual quality.

Automatic quality and encoding settings

Cloudinary's intelligent quality and encoding algorithm analyzes an image to find the best quality compression level and optimal encoding settings based on the image content and the viewing browser, in order to produce an image with good visual quality while minimizing the file size. Cloudinary automates the file size versus quality trade-off decision, on the fly, by using perceptual metrics and heuristics that tune the quality settings based on the specific image content and format. Analyzing every image individually to find the optimal compression level and image encoding settings allows for precise adjustment of the compression level complemented by fine tuning of the encoding settings, and can significantly reduce the file size without any degradation noticeable to the human eye.

The quality transformation parameter can be set to auto (q_auto in URLs) in order to perform automatic quality selection and image encoding adjustments. Further control of the automatic quality selection is supported as follows:

  • q_auto - The optimal balance between file size and visual quality. By default, this is the same as q_auto:good, while it can automatically switch to the more aggressive q_auto:eco mode (see the note on Save-data support below).
  • q_auto:best - Less aggressive algorithm. Generates bigger files with potentially better visual quality. Example of a target audience: photography sites that display images with a high visual quality.
  • q_auto:good - Ensuring a relatively small file size with good visual quality.
  • q_auto:eco - More aggressive algorithm, which results in smaller files of slightly lower visual quality. Example of a target audience: popular sites and social networks with a huge amount of traffic.
  • q_auto:low - Most aggressive algorithm, which results in the smallest files of low visual quality. Example of a target audience: sites using thumbnail images that link to higher quality images.

Examples of the resulting file size when encoding a photograph, using various regular and automatic quality parameter values:

Original Original (569KB) q_80 q_80 (80.3KB) q_auto:best q_auto:best (65.9KB) q_auto:good q_auto:good (56.9KB) q_auto:eco q_auto:eco (45.0KB) q_auto:low q_auto:low (35.0KB)

Ruby:
cl_image_tag("woman.jpg", :quality=>"auto")
PHP:
cl_image_tag("woman.jpg", array("quality"=>"auto"))
Python:
CloudinaryImage("woman.jpg").image(quality="auto")
Node.js:
cloudinary.image("woman.jpg", {quality: "auto"})
Java:
cloudinary.url().transformation(new Transformation().quality("auto")).imageTag("woman.jpg")
jQuery:
$.cloudinary.image("woman.jpg", {quality: "auto"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Quality("auto")).BuildImageTag("woman.jpg")

Examples of the resulting file size when encoding a drawing, using regular and automatic quality values:

Original Original (296KB) q_80 q_80 (223KB) q_auto:best q_auto:best (226KB) q_auto:good q_auto:good (156KB) q_auto:eco q_auto:eco (97.5KB) q_auto:low q_auto:low (87.5KB)

Ruby:
cl_image_tag("robot.jpg", :quality=>"auto")
PHP:
cl_image_tag("robot.jpg", array("quality"=>"auto"))
Python:
CloudinaryImage("robot.jpg").image(quality="auto")
Node.js:
cloudinary.image("robot.jpg", {quality: "auto"})
Java:
cloudinary.url().transformation(new Transformation().quality("auto")).imageTag("robot.jpg")
jQuery:
$.cloudinary.image("robot.jpg", {quality: "auto"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Quality("auto")).BuildImageTag("robot.jpg")

Notes:

  • q_auto cannot be used within named transformations, however q_auto:[Mode] (e.g., q_auto:good) is supported within named transformations.
  • Save-Data support is a feature included in the Client-Hints standard, which is already supported by Chrome and Opera browsers. The browsers send a special request header named 'Save-Data' if the user has enabled data saving mode. When q_auto is specified and the 'Save-Data: on' header reaches the CDN layer of Cloudinary, image compression and encoding will automatically switch to the eco mode (q_auto:eco) instead of the default good quality mode (q_auto:good).
  • Override automatic quality: you can override the automatic quality algorithm and set a fixed quality value for a specific image in the media library.

Toggling chroma subsampling

Chroma subsampling is a method of encoding images by implementing less resolution for chroma information (colors) than for luma information (luminance), taking advantage of the human visual system's lower acuity for color differences than for luminance. To override the default behavior of whether to perform chroma subsampling, a separate value can be added to the quality parameter as follows:

  • 444 can be added to prevent subsampling. For example: q_80:444
  • 420 can be added to force subsampling. For example: q_95:420.

Modify image shape and style

Cloudinary supports various transformations for modifying the shape and style of images. This section contains information on the following topics:

Rounding corners and creating circular images

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 generate 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. Having images with rounded corners is also great 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) set to the number of pixels the radius of all four corners should be.

The following example transforms an uploaded JPEG to a 150x100 PNG with rounded corners of 20 pixels. Note that the conversion to PNG is needed for supporting a transparent background (the PNG format produces larger files than the JPEG format: see the article on PNG optimization - saving bandwidth on transparent PNGs with dynamic underlay for more information).

Ruby:
cl_image_tag("sample.png", :width=>150, :height=>100, :radius=>20, :crop=>"fill")
PHP:
cl_image_tag("sample.png", array("width"=>150, "height"=>100, "radius"=>20, "crop"=>"fill"))
Python:
CloudinaryImage("sample.png").image(width=150, height=100, radius=20, crop="fill")
Node.js:
cloudinary.image("sample.png", {width: 150, height: 100, radius: 20, crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(150).height(100).radius(20).crop("fill")).imageTag("sample.png")
jQuery:
$.cloudinary.image("sample.png", {width: 150, height: 100, radius: 20, crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(150).Height(100).Radius(20).Crop("fill")).BuildImageTag("sample.png")
150x100 PNG with rounded corners set to 20 pixels

Cloudinary supports cropping images to the shape of an ellipse or a circle (if the requested width and height are the same). Simply pass max as the value of the radius parameter.

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

Ruby:
cl_image_tag("sample.png", :width=>250, :height=>150, :radius=>"max", :crop=>"fill")
PHP:
cl_image_tag("sample.png", array("width"=>250, "height"=>150, "radius"=>"max", "crop"=>"fill"))
Python:
CloudinaryImage("sample.png").image(width=250, height=150, radius="max", crop="fill")
Node.js:
cloudinary.image("sample.png", {width: 250, height: 150, radius: "max", crop: "fill"})
Java:
cloudinary.url().transformation(new Transformation().width(250).height(150).radius("max").crop("fill")).imageTag("sample.png")
jQuery:
$.cloudinary.image("sample.png", {width: 250, height: 150, radius: "max", crop: "fill"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(250).Height(150).Radius("max").Crop("fill")).BuildImageTag("sample.png")
150x100 ellipsoid image

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

Ruby:
cl_image_tag("face_left.png", :width=>200, :height=>200, :gravity=>"face", :radius=>"max", :crop=>"thumb")
PHP:
cl_image_tag("face_left.png", array("width"=>200, "height"=>200, "gravity"=>"face", "radius"=>"max", "crop"=>"thumb"))
Python:
CloudinaryImage("face_left.png").image(width=200, height=200, gravity="face", radius="max", crop="thumb")
Node.js:
cloudinary.image("face_left.png", {width: 200, height: 200, gravity: "face", radius: "max", crop: "thumb"})
Java:
cloudinary.url().transformation(new Transformation().width(200).height(200).gravity("face").radius("max").crop("thumb")).imageTag("face_left.png")
jQuery:
$.cloudinary.image("face_left.png", {width: 200, height: 200, gravity: "face", radius: "max", crop: "thumb"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(200).Height(200).Gravity("face").Radius("max").Crop("thumb")).BuildImageTag("face_left.png")
100x100 face thumbnail with max radius

Displaying overlay pictures of your web site's users as nice looking circles on other images is made possible with the layer_apply flag that tells Cloudinary to apply the transformations to the overlay image and not the base image:

Ruby:
cl_image_tag("flower.jpg", :transformation=>[
  {:width=>200, :height=>200, :gravity=>"face", :radius=>"max", :overlay=>"face_left", :crop=>"thumb"},
  {:flags=>"layer_apply", :gravity=>"north_east"}
  ])
PHP:
cl_image_tag("flower.jpg", array("transformation"=>array(
  array("width"=>200, "height"=>200, "gravity"=>"face", "radius"=>"max", "overlay"=>"face_left", "crop"=>"thumb"),
  array("flags"=>"layer_apply", "gravity"=>"north_east")
  )))
Python:
CloudinaryImage("flower.jpg").image(transformation=[
  {"width": 200, "height": 200, "gravity": "face", "radius": "max", "overlay": "face_left", "crop": "thumb"},
  {"flags": "layer_apply", "gravity": "north_east"}
  ])
Node.js:
cloudinary.image("flower.jpg", {transformation: [
  {width: 200, height: 200, gravity: "face", radius: "max", overlay: "face_left", crop: "thumb"},
  {flags: "layer_apply", gravity: "north_east"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(200).height(200).gravity("face").radius("max").overlay("face_left").crop("thumb").chain()
  .flags("layer_apply").gravity("north_east")).imageTag("flower.jpg")
jQuery:
$.cloudinary.image("flower.jpg", {transformation: [
  {width: 200, height: 200, gravity: "face", radius: "max", overlay: "face_left", crop: "thumb"},
  {flags: "layer_apply", gravity: "north_east"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(200).Height(200).Gravity("face").Radius("max").Overlay("face_left").Crop("thumb").Chain()
  .Flags("layer_apply").Gravity("north_east")).BuildImageTag("flower.jpg")
Face thumbnail on base image

Rotating images

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.

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 that you can apply multiple values when each value is separated 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:
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>100},
      {:angle=>90}
      ])
    PHP:
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>100),
      array("angle"=>90)
      )))
    Python:
    CloudinaryImage("sample.jpg").image(transformation=[
      {"width": 100},
      {"angle": 90}
      ])
    Node.js:
    cloudinary.image("sample.jpg", {transformation: [
      {width: 100},
      {angle: 90}
      ]})
    Java:
    cloudinary.url().transformation(new Transformation()
      .width(100).chain()
      .angle(90)).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 100},
      {angle: 90}
      ]})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(100).Chain()
      .Angle(90)).BuildImageTag("sample.jpg")
    Image rotated 90 degrees clockwise
  2. Rotate the image by -20 degrees (automatically adds a bounding box):
    Ruby:
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>100},
      {:angle=>-20}
      ])
    PHP:
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>100),
      array("angle"=>-20)
      )))
    Python:
    CloudinaryImage("sample.jpg").image(transformation=[
      {"width": 100},
      {"angle": -20}
      ])
    Node.js:
    cloudinary.image("sample.jpg", {transformation: [
      {width: 100},
      {angle: -20}
      ]})
    Java:
    cloudinary.url().transformation(new Transformation()
      .width(100).chain()
      .angle(-20)).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 100},
      {angle: -20}
      ]})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(100).Chain()
      .Angle(-20)).BuildImageTag("sample.jpg")
    Image rotated 20 degrees counterclockwise
  3. Vertically mirror flip the image and rotate by 70 degrees (automatically adds a bounding box):
    Ruby:
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>100},
      {:angle=>["vflip", 45]}
      ])
    PHP:
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>100),
      array("angle"=>array("vflip", 45))
      )))
    Python:
    CloudinaryImage("sample.jpg").image(transformation=[
      {"width": 100},
      {"angle": ["vflip", 45]}
      ])
    Node.js:
    cloudinary.image("sample.jpg", {transformation: [
      {width: 100},
      {angle: ["vflip", 45]}
      ]})
    Java:
    cloudinary.url().transformation(new Transformation()
      .width(100).chain()
      .angle("vflip", "45")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 100},
      {angle: ["vflip", 45]}
      ]})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(100).Chain()
      .Angle("vflip", "45")).BuildImageTag("sample.jpg")
    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:
    cl_image_tag("sample.jpg", :transformation=>[
      {:width=>200, :height=>200, :radius=>"max", :crop=>"fill"},
      {:angle=>30},
      {:effect=>"trim"}
      ])
    PHP:
    cl_image_tag("sample.jpg", array("transformation"=>array(
      array("width"=>200, "height"=>200, "radius"=>"max", "crop"=>"fill"),
      array("angle"=>30),
      array("effect"=>"trim")
      )))
    Python:
    CloudinaryImage("sample.jpg").image(transformation=[
      {"width": 200, "height": 200, "radius": "max", "crop": "fill"},
      {"angle": 30},
      {"effect": "trim"}
      ])
    Node.js:
    cloudinary.image("sample.jpg", {transformation: [
      {width: 200, height: 200, radius: "max", crop: "fill"},
      {angle: 30},
      {effect: "trim"}
      ]})
    Java:
    cloudinary.url().transformation(new Transformation()
      .width(200).height(200).radius("max").crop("fill").chain()
      .angle(30).chain()
      .effect("trim")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {transformation: [
      {width: 200, height: 200, radius: "max", crop: "fill"},
      {angle: 30},
      {effect: "trim"}
      ]})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Width(200).Height(200).Radius("max").Crop("fill").Chain()
      .Angle(30).Chain()
      .Effect("trim")).BuildImageTag("sample.jpg")
    image cropped to a 200x200 circle, rotated 30 degrees clockwise and trimmed

Controlling image opacity

Adjust the opacity of an image with the opacity parameter (o in URLs). The parameter accepts a value between 0-100 representing the percentage of transparency, where 100 means completely opaque and 0 is completely transparent.

Note: If the image format does not support transparency, the background color is used instead as a base (white by default). The color can be changed with the background parameter.

For example, the uploaded image named sample delivered with 30% opacity:

Ruby:
cl_image_tag("sample.jpg", :opacity=>30)
PHP:
cl_image_tag("sample.jpg", array("opacity"=>30))
Python:
CloudinaryImage("sample.jpg").image(opacity=30)
Node.js:
cloudinary.image("sample.jpg", {opacity: 30})
Java:
cloudinary.url().transformation(new Transformation().opacity(30)).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {opacity: 30})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Opacity(30)).BuildImageTag("sample.jpg")
Image delivered with 50% opacity

Controlling the opacity is especially useful when placing other images as overlays. For example, an overlay of cloudinary_icon added with 60% opacity:

Ruby:
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon", :width=>300, :gravity=>"north_east", :opacity=>60)
PHP:
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon", "width"=>300, "gravity"=>"north_east", "opacity"=>60))
Python:
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon", width=300, gravity="north_east", opacity=60)
Node.js:
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", width: 300, gravity: "north_east", opacity: 60})
Java:
cloudinary.url().transformation(new Transformation().overlay("cloudinary_icon").width(300).gravity("north_east").opacity(60)).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", width: 300, gravity: "north_east", opacity: 60})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("cloudinary_icon").Width(300).Gravity("north_east").Opacity(60)).BuildImageTag("sample.jpg")
Overlay added with 60% opacity

Adding image borders

Add a solid border around the 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:
cl_image_tag("sample.jpg", :border=>"5px_solid_red")
PHP:
cl_image_tag("sample.jpg", array("border"=>"5px_solid_red"))
Python:
CloudinaryImage("sample.jpg").image(border="5px_solid_red")
Node.js:
cloudinary.image("sample.jpg", {border: "5px_solid_red"})
Java:
cloudinary.url().transformation(new Transformation().border("5px_solid_red")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {border: "5px_solid_red"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Border("5px_solid_red")).BuildImageTag("sample.jpg")
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:
cl_image_tag("lady.jpg", :transformation=>[
  {:gravity=>"face", :radius=>75, :border=>"10px_solid_grey", :crop=>"crop"},
  {:overlay=>"young_couple", :width=>150, :height=>150, :radius=>"max", :gravity=>"faces", :border=>"3px_solid_black", :crop=>"thumb"},
  {:flags=>"layer_apply", :gravity=>"north_east"}
  ])
PHP:
cl_image_tag("lady.jpg", array("transformation"=>array(
  array("gravity"=>"face", "radius"=>75, "border"=>"10px_solid_grey", "crop"=>"crop"),
  array("overlay"=>"young_couple", "width"=>150, "height"=>150, "radius"=>"max", "gravity"=>"faces", "border"=>"3px_solid_black", "crop"=>"thumb"),
  array("flags"=>"layer_apply", "gravity"=>"north_east")
  )))
Python:
CloudinaryImage("lady.jpg").image(transformation=[
  {"gravity": "face", "radius": 75, "border": "10px_solid_grey", "crop": "crop"},
  {"overlay": "young_couple", "width": 150, "height": 150, "radius": "max", "gravity": "faces", "border": "3px_solid_black", "crop": "thumb"},
  {"flags": "layer_apply", "gravity": "north_east"}
  ])
Node.js:
cloudinary.image("lady.jpg", {transformation: [
  {gravity: "face", radius: 75, border: "10px_solid_grey", crop: "crop"},
  {overlay: "young_couple", width: 150, height: 150, radius: "max", gravity: "faces", border: "3px_solid_black", crop: "thumb"},
  {flags: "layer_apply", gravity: "north_east"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .gravity("face").radius(75).border("10px_solid_grey").crop("crop").chain()
  .overlay("young_couple").width(150).height(150).radius("max").gravity("faces").border("3px_solid_black").crop("thumb").chain()
  .flags("layer_apply").gravity("north_east")).imageTag("lady.jpg")
jQuery:
$.cloudinary.image("lady.jpg", {transformation: [
  {gravity: "face", radius: 75, border: "10px_solid_grey", crop: "crop"},
  {overlay: "young_couple", width: 150, height: 150, radius: "max", gravity: "faces", border: "3px_solid_black", crop: "thumb"},
  {flags: "layer_apply", gravity: "north_east"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Gravity("face").Radius(75).Border("10px_solid_grey").Crop("crop").Chain()
  .Overlay("young_couple").Width(150).Height(150).Radius("max").Gravity("faces").Border("3px_solid_black").Crop("thumb").Chain()
  .Flags("layer_apply").Gravity("north_east")).BuildImageTag("lady.jpg")
Base image with rounded corners + overlay with rounded corners

Setting 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 the “pad” crop mode, 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:
cl_image_tag("sample.jpg", :width=>300, :height=>300, :background=>"green", :crop=>"pad")
PHP:
cl_image_tag("sample.jpg", array("width"=>300, "height"=>300, "background"=>"green", "crop"=>"pad"))
Python:
CloudinaryImage("sample.jpg").image(width=300, height=300, background="green", crop="pad")
Node.js:
cloudinary.image("sample.jpg", {width: 300, height: 300, background: "green", crop: "pad"})
Java:
cloudinary.url().transformation(new Transformation().width(300).height(300).background("green").crop("pad")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {width: 300, height: 300, background: "green", crop: "pad"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(300).Height(300).Background("green").Crop("pad")).BuildImageTag("sample.jpg")
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).

Applying image effects and filters

Apply a filter or an effect on an image with the effect parameter (e in URLs). The value of the parameter includes the name of the effect and sometimes an additional value that controls the behavior of the specific effect. Cloudinary supports a large number of effects 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.

There are a large number of effects and filters available, which can be roughly divided into the following type of effects:

For a full list of all the supported effects, see the Image transformations reference table. For more information on using effects see the following articles:

Tip: In addition to the various image effects and filters described here, you can also apply a 3D LUT file as an image overlay to achieve desired effects.

Color balance and level effects

Effects: hue, red, blue, green, negate, brightness, brightness_hsb, colorize, grayscale, blackwhite, sepia, saturation

These effects are useful for changing the intensities of colors in an image, correcting color imbalance, applying colorization filters, and removing colors.

Examples:

  1. Converting the sample image to grayscale:
    Ruby:
    cl_image_tag("sample.jpg", :effect=>"grayscale")
    PHP:
    cl_image_tag("sample.jpg", array("effect"=>"grayscale"))
    Python:
    CloudinaryImage("sample.jpg").image(effect="grayscale")
    Node.js:
    cloudinary.image("sample.jpg", {effect: "grayscale"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("grayscale")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {effect: "grayscale"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("grayscale")).BuildImageTag("sample.jpg")
    Image in grayscale
  2. Increasing saturation of the sample image to 50:
    Ruby:
    cl_image_tag("sample.jpg", :effect=>"saturation:50")
    PHP:
    cl_image_tag("sample.jpg", array("effect"=>"saturation:50"))
    Python:
    CloudinaryImage("sample.jpg").image(effect="saturation:50")
    Node.js:
    cloudinary.image("sample.jpg", {effect: "saturation:50"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("saturation:50")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {effect: "saturation:50"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("saturation:50")).BuildImageTag("sample.jpg")
    Image with saturation:50

Tint effects

The tint:<options> effect enables you to blend your images with one or more colors and specify the blend strength. Advanced users can also equalize the image for increased contrast and specify the positioning of the gradient blend for each color.

  • By default, e_tint applies a red color at 60% blend strength.

  • Specify the colors and blend strength amount in the format:

    e_tint:[amount]:[color1]:[color2]:...:[color10].

    amount is a value from 0-100, where 0 keeps the original color and 100 blends the specified colors completely.

    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:

    Ruby:
    cl_image_tag("greece_landscape.jpg", :effect=>"tint:100:red:blue:yellow")
    PHP:
    cl_image_tag("greece_landscape.jpg", array("effect"=>"tint:100:red:blue:yellow"))
    Python:
    CloudinaryImage("greece_landscape.jpg").image(effect="tint:100:red:blue:yellow")
    Node.js:
    cloudinary.image("greece_landscape.jpg", {effect: "tint:100:red:blue:yellow"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("tint:100:red:blue:yellow")).imageTag("greece_landscape.jpg")
    jQuery:
    $.cloudinary.image("greece_landscape.jpg", {effect: "tint:100:red:blue:yellow"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("tint:100:red:blue:yellow")).BuildImageTag("greece_landscape.jpg")

  • To equalize the colors in your image before tinting, set equalize to true (false by default). For example:

    Ruby:
    cl_image_tag("greece_landscape.jpg", :effect=>"tint:equalize:80:red:blue:yellow")
    PHP:
    cl_image_tag("greece_landscape.jpg", array("effect"=>"tint:equalize:80:red:blue:yellow"))
    Python:
    CloudinaryImage("greece_landscape.jpg").image(effect="tint:equalize:80:red:blue:yellow")
    Node.js:
    cloudinary.image("greece_landscape.jpg", {effect: "tint:equalize:80:red:blue:yellow"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("tint:equalize:80:red:blue:yellow")).imageTag("greece_landscape.jpg")
    jQuery:
    $.cloudinary.image("greece_landscape.jpg", {effect: "tint:equalize:80:red:blue:yellow"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("tint:equalize:80:red:blue:yellow")).BuildImageTag("greece_landscape.jpg")

  • By default, the specified colors are distributed evenly. To adjust the positioning of the gradient blend, specify a position value between 0p-100p. If specifying positioning, you must specify a position value for all colors. For example:

    Ruby:
    cl_image_tag("greece_landscape.jpg", :effect=>"tint:equalize:80:red:50p:blue:60p:yellow:40p")
    PHP:
    cl_image_tag("greece_landscape.jpg", array("effect"=>"tint:equalize:80:red:50p:blue:60p:yellow:40p"))
    Python:
    CloudinaryImage("greece_landscape.jpg").image(effect="tint:equalize:80:red:50p:blue:60p:yellow:40p")
    Node.js:
    cloudinary.image("greece_landscape.jpg", {effect: "tint:equalize:80:red:50p:blue:60p:yellow:40p"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("tint:equalize:80:red:50p:blue:60p:yellow:40p")).imageTag("greece_landscape.jpg")
    jQuery:
    $.cloudinary.image("greece_landscape.jpg", {effect: "tint:equalize:80:red:50p:blue:60p:yellow:40p"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("tint:equalize:80:red:50p:blue:60p:yellow:40p")).BuildImageTag("greece_landscape.jpg")

Original Original default red color at 20% strength default red color at 20% strength red, blue, yellow  at 100% strength red, blue, yellow at 100% strength equalized, red, blue, yellow tinting at 80% strength, with adjusted gradients equalized, mutli-color, 80%, adjusted gradients

1Equalizing colors redistributes the pixels in your image so that they are equally balanced across the entire range of brightness values, which increases the overall contrast in the image. The lightest area is remapped to pure white, and the darkest area is remapped to pure black.

Blurring, pixelating and sharpening effects

Effects: blur, sharpen, unsharp_mask, blur_region, blur_faces, pixelate, pixelate_faces, ordered_dither, noise, vignette, gradient_fade, tilt_shift

These effects are used to either visually distort or visually enhance an image.

Examples:

  1. To apply a strong blurring filter (300) to the sample image:
    Ruby:
    cl_image_tag("sample.jpg", :effect=>"blur:300")
    PHP:
    cl_image_tag("sample.jpg", array("effect"=>"blur:300"))
    Python:
    CloudinaryImage("sample.jpg").image(effect="blur:300")
    Node.js:
    cloudinary.image("sample.jpg", {effect: "blur:300"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("blur:300")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {effect: "blur:300"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("blur:300")).BuildImageTag("sample.jpg")
    Image with blur of 300
  2. To apply a sharpen filter to the sample image:
    Ruby:
    cl_image_tag("sample.jpg", :effect=>"sharpen")
    PHP:
    cl_image_tag("sample.jpg", array("effect"=>"sharpen"))
    Python:
    CloudinaryImage("sample.jpg").image(effect="sharpen")
    Node.js:
    cloudinary.image("sample.jpg", {effect: "sharpen"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("sharpen")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {effect: "sharpen"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("sharpen")).BuildImageTag("sample.jpg")
    Image with sharpen

Overlay blending effects

Effects: screen, multiply, overlay, mask

These effects are used for blending an overlay with an image.

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

Ruby:
cl_image_tag("sample.jpg", :effect=>"screen", :overlay=>"cloudinary_icon")
PHP:
cl_image_tag("sample.jpg", array("effect"=>"screen", "overlay"=>"cloudinary_icon"))
Python:
CloudinaryImage("sample.jpg").image(effect="screen", overlay="cloudinary_icon")
Node.js:
cloudinary.image("sample.jpg", {effect: "screen", overlay: "cloudinary_icon"})
Java:
cloudinary.url().transformation(new Transformation().effect("screen").overlay("cloudinary_icon")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {effect: "screen", overlay: "cloudinary_icon"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("screen").Overlay("cloudinary_icon")).BuildImageTag("sample.jpg")
Image made brighter according to overlay

Image shape changes and distortion effects

Effects: shadow, make_transparent, trim, distort, shear, displace

These effects are used to morph an image's visual dimensions.

Examples:

  1. To distort the sample image to a new shape (see the article on How to dynamically distort images to fit your graphic design for more info:
    Ruby:
    cl_image_tag("sample.jpg", :width=>300, :effect=>"distort:40:25:280:60:260:155:35:165")
    PHP:
    cl_image_tag("sample.jpg", array("width"=>300, "effect"=>"distort:40:25:280:60:260:155:35:165"))
    Python:
    CloudinaryImage("sample.jpg").image(width=300, effect="distort:40:25:280:60:260:155:35:165")
    Node.js:
    cloudinary.image("sample.jpg", {width: 300, effect: "distort:40:25:280:60:260:155:35:165"})
    Java:
    cloudinary.url().transformation(new Transformation().width(300).effect("distort:40:25:280:60:260:155:35:165")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {width: 300, effect: "distort:40:25:280:60:260:155:35:165"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Width(300).Effect("distort:40:25:280:60:260:155:35:165")).BuildImageTag("sample.jpg")
    Image distorted to new shape
  2. To add a custom green shadow to the sample image:
    Ruby:
    cl_image_tag("sample.jpg", :color=>"#009900", :effect=>"shadow:50", :x=>10, :y=>10)
    PHP:
    cl_image_tag("sample.jpg", array("color"=>"#009900", "effect"=>"shadow:50", "x"=>10, "y"=>10))
    Python:
    CloudinaryImage("sample.jpg").image(color="#009900", effect="shadow:50", x=10, y=10)
    Node.js:
    cloudinary.image("sample.jpg", {color: "#009900", effect: "shadow:50", x: 10, y: 10})
    Java:
    cloudinary.url().transformation(new Transformation().color("#009900").effect("shadow:50").x(10).y(10)).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {color: "#009900", effect: "shadow:50", x: 10, y: 10})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Color("#009900").Effect("shadow:50").X(10).Y(10)).BuildImageTag("sample.jpg")
    Green shadow

Image improvement effects

Effects: improve, gamma, auto_brightness, auto_contrast, auto_color, fill_light, vibrance, contrast, viesus_correct

These effects are used for manually adjusting the visual quality of an image, or applying automatic visual enhancements.

Examples:

  1. To improve an image by automatically adjusting image colors, contrast and lightness:
    Ruby:
    cl_image_tag("sample.jpg", :effect=>"improve")
    PHP:
    cl_image_tag("sample.jpg", array("effect"=>"improve"))
    Python:
    CloudinaryImage("sample.jpg").image(effect="improve")
    Node.js:
    cloudinary.image("sample.jpg", {effect: "improve"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("improve")).imageTag("sample.jpg")
    jQuery:
    $.cloudinary.image("sample.jpg", {effect: "improve"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("improve")).BuildImageTag("sample.jpg")
    Image automatically improved
  2. To automatically enhance an image using the Viesus automatic enhancement add-on:
    Ruby:
    cl_image_tag("beach.jpg", :effect=>"viesus_correct")
    PHP:
    cl_image_tag("beach.jpg", array("effect"=>"viesus_correct"))
    Python:
    CloudinaryImage("beach.jpg").image(effect="viesus_correct")
    Node.js:
    cloudinary.image("beach.jpg", {effect: "viesus_correct"})
    Java:
    cloudinary.url().transformation(new Transformation().effect("viesus_correct")).imageTag("beach.jpg")
    jQuery:
    $.cloudinary.image("beach.jpg", {effect: "viesus_correct"})
    .Net:
    cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("viesus_correct")).BuildImageTag("beach.jpg")
    Image automatically enhanced with Viesus

Artistic filter effects

The art:<filter> effects brighten highlights, intensify shadows, apply sepia-like filters, add vignetting, and more.

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:
cl_image_tag("horses.jpg", :effect=>"art:zorro")
PHP:
cl_image_tag("horses.jpg", array("effect"=>"art:zorro"))
Python:
CloudinaryImage("horses.jpg").image(effect="art:zorro")
Node.js:
cloudinary.image("horses.jpg", {effect: "art:zorro"})
Java:
cloudinary.url().transformation(new Transformation().effect("art:zorro")).imageTag("horses.jpg")
jQuery:
$.cloudinary.image("horses.jpg", {effect: "art:zorro"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("art:zorro")).BuildImageTag("horses.jpg")

Miscellaneous image effects

Effects: oil_paint, red_eye, adv_redeye

This category includes other effects that don't fall under one of the other categories.

For example, to apply an oil-painting filter to the sample image:

Ruby:
cl_image_tag("sample.jpg", :effect=>"oil_paint:70")
PHP:
cl_image_tag("sample.jpg", array("effect"=>"oil_paint:70"))
Python:
CloudinaryImage("sample.jpg").image(effect="oil_paint:70")
Node.js:
cloudinary.image("sample.jpg", {effect: "oil_paint:70"})
Java:
cloudinary.url().transformation(new Transformation().effect("oil_paint:70")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {effect: "oil_paint:70"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("oil_paint:70")).BuildImageTag("sample.jpg")
Image with oil-painting filter

Image and text overlays

You can dynamically add overlays, underlays and text captions to specific locations within your images, while easily manipulating and transforming them to suit your needs. This section is divided into the following topics:

Adding image overlays

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

Ruby:
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon")
PHP:
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon"))
Python:
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon")
Node.js:
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon"})
Java:
cloudinary.url().transformation(new Transformation().overlay("cloudinary_icon")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {overlay: "cloudinary_icon"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("cloudinary_icon")).BuildImageTag("sample.jpg")
Image with overlay

Manipulating overlays

The overlay can be resized and manipulated like any other image uploaded to Cloudinary. For example, adding an overlay of the image called cloudinary_icon to the top right corner of the sample image, where the overlay is also scaled down to 90% of its original width and made into a watermark by reducing the opacity to 70% and increasing the brightness to 50% using the brightness effect:

Ruby:
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon", :width=>0.9, :gravity=>"north_east", :opacity=>70, :effect=>"brightness:50", :crop=>"scale")
PHP:
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon", "width"=>0.9, "gravity"=>"north_east", "opacity"=>70, "effect"=>"brightness:50", "crop"=>"scale"))
Python:
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon", width=0.9, gravity="north_east", opacity=70, effect="brightness:50", crop="scale")
Node.js:
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", width: 0.9, gravity: "north_east", opacity: 70, effect: "brightness:50", crop: "scale"})
Java:
cloudinary.url().transformation(new Transformation().overlay("cloudinary_icon").width(0.9).gravity("north_east").opacity(70).effect("brightness:50").crop("scale")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", width: 0.9, gravity: "north_east", opacity: 70, effect: "brightness:50", crop: "scale"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("cloudinary_icon").Width(0.9).Gravity("north_east").Opacity(70).Effect("brightness:50").Crop("scale")).BuildImageTag("sample.jpg")
Image with transformed overlay

You can also add the relative flag (fl_relative in URLs) to specify that percentage-based width & height parameters of overlays (e.g., w_0.5) are relative to the size of the base image instead of the original size of the overlaying image itself. For example, adding an overlay of the image called cloudinary_icon to the jpg image named sample, where the overlay is resized to 80% of the width of the base image:

Ruby:
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon", :width=>0.8, :flags=>"relative")
PHP:
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon", "width"=>0.8, "flags"=>"relative"))
Python:
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon", width=0.8, flags="relative")
Node.js:
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", width: 0.8, flags: "relative"})
Java:
cloudinary.url().transformation(new Transformation().overlay("cloudinary_icon").width(0.8).flags("relative")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", width: 0.8, flags: "relative"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("cloudinary_icon").Width(0.8).Flags("relative")).BuildImageTag("sample.jpg")
Image with overlay resized relative to base image

Placing overlays

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

Ruby:
cl_image_tag("sample.jpg", :overlay=>"cloudinary_icon", :gravity=>"north_west", :y=>20)
PHP:
cl_image_tag("sample.jpg", array("overlay"=>"cloudinary_icon", "gravity"=>"north_west", "y"=>20))
Python:
CloudinaryImage("sample.jpg").image(overlay="cloudinary_icon", gravity="north_west", y=20)
Node.js:
cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", gravity: "north_west", y: 20})
Java:
cloudinary.url().transformation(new Transformation().overlay("cloudinary_icon").gravity("north_west").y(20)).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {overlay: "cloudinary_icon", gravity: "north_west", y: 20})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("cloudinary_icon").Gravity("north_west").Y(20)).BuildImageTag("sample.jpg")
Image with precisely placed overlay

The gravity parameter can also be set to one of the facial detection modes, and the detected facial coordinates become the focus when placing the overlay. If there are multiple faces in an image, setting the gravity parameter to 'faces' will result in the overlay being placed multiple times, once for each face detected. For example, adding an overlay of the golden_star image over all faces detected in the couple image. The star image is also resized to 110% of the detected width of each face by adding the region_relative flag:

Ruby:
cl_image_tag("couple.jpg", :overlay=>"golden_star", :gravity=>"faces", :width=>1.1, :flags=>"region_relative")
PHP:
cl_image_tag("couple.jpg", array("overlay"=>"golden_star", "gravity"=>"faces", "width"=>1.1, "flags"=>"region_relative"))
Python:
CloudinaryImage("couple.jpg").image(overlay="golden_star", gravity="faces", width=1.1, flags="region_relative")
Node.js:
cloudinary.image("couple.jpg", {overlay: "golden_star", gravity: "faces", width: 1.1, flags: "region_relative"})
Java:
cloudinary.url().transformation(new Transformation().overlay("golden_star").gravity("faces").width(1.1).flags("region_relative")).imageTag("couple.jpg")
jQuery:
$.cloudinary.image("couple.jpg", {overlay: "golden_star", gravity: "faces", width: 1.1, flags: "region_relative"})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Overlay("golden_star").Gravity("faces").Width(1.1).Flags("region_relative")).BuildImageTag("couple.jpg")
Image with overlay placed over faces

Note: When gravity is set to one of the facial detection values and no face is detected in the image, then no overlay is placed at all.

Tiling overlays

Instead of adding the overlay to a single specific location, you can tile the image within the entire image by adding the tiled flag (fl_tiled in URLs). For example, tiling an overlay of the image called cloudinary_icon on to the jpg image named flowers, with the overlay's opacity set to 50% and scaled to a width of 100 pixels:

Ruby:
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500},
  {:overlay=>"cloudinary_icon", :opacity=>50, :width=>100, :effect=>"brightness:200", :flags=>"tiled"}
  ])
PHP:
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500),
  array("overlay"=>"cloudinary_icon", "opacity"=>50, "width"=>100, "effect"=>"brightness:200", "flags"=>"tiled")
  )))
Python:
CloudinaryImage("flowers.jpg").image(transformation=[
  {"width": 500},
  {"overlay": "cloudinary_icon", "opacity": 50, "width": 100, "effect": "brightness:200", "flags": "tiled"}
  ])
Node.js:
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "cloudinary_icon", opacity: 50, width: 100, effect: "brightness:200", flags: "tiled"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(500).chain()
  .overlay("cloudinary_icon").opacity(50).width(100).effect("brightness:200").flags("tiled")).imageTag("flowers.jpg")
jQuery:
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "cloudinary_icon", opacity: 50, width: 100, effect: "brightness:200", flags: "tiled"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Chain()
  .Overlay("cloudinary_icon").Opacity(50).Width(100).Effect("brightness:200").Flags("tiled")).BuildImageTag("flowers.jpg")
Image with tiled overlay

Applying chained transformations to overlays

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

For example, the sample image scaled to a width of 500 pixels before adding the woman image as an overlay, where the overlay image is automatically cropped to only include the detected faces and then scaled to a width of 150 pixels:

Ruby:
cl_image_tag("sample.jpg", :transformation=>[
  {:width=>500},
  {:effect=>"brightness:70"},
  {:overlay=>"woman", :gravity=>"face", :crop=>"crop"},
  {:width=>150},
  {:effect=>"saturation:50"},
  {:effect=>"shadow"},
  {:flags=>"layer_apply"}
  ])
PHP:
cl_image_tag("sample.jpg", array("transformation"=>array(
  array("width"=>500),
  array("effect"=>"brightness:70"),
  array("overlay"=>"woman", "gravity"=>"face", "crop"=>"crop"),
  array("width"=>150),
  array("effect"=>"saturation:50"),
  array("effect"=>"shadow"),
  array("flags"=>"layer_apply")
  )))
Python:
CloudinaryImage("sample.jpg").image(transformation=[
  {"width": 500},
  {"effect": "brightness:70"},
  {"overlay": "woman", "gravity": "face", "crop": "crop"},
  {"width": 150},
  {"effect": "saturation:50"},
  {"effect": "shadow"},
  {"flags": "layer_apply"}
  ])
Node.js:
cloudinary.image("sample.jpg", {transformation: [
  {width: 500},
  {effect: "brightness:70"},
  {overlay: "woman", gravity: "face", crop: "crop"},
  {width: 150},
  {effect: "saturation:50"},
  {effect: "shadow"},
  {flags: "layer_apply"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(500).chain()
  .effect("brightness:70").chain()
  .overlay("woman").gravity("face").crop("crop").chain()
  .width(150).chain()
  .effect("saturation:50").chain()
  .effect("shadow").chain()
  .flags("layer_apply")).imageTag("sample.jpg")
jQuery:
$.cloudinary.image("sample.jpg", {transformation: [
  {width: 500},
  {effect: "brightness:70"},
  {overlay: "woman", gravity: "face", crop: "crop"},
  {width: 150},
  {effect: "saturation:50"},
  {effect: "shadow"},
  {flags: "layer_apply"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Chain()
  .Effect("brightness:70").Chain()
  .Overlay("woman").Gravity("face").Crop("crop").Chain()
  .Width(150).Chain()
  .Effect("saturation:50").Chain()
  .Effect("shadow").Chain()
  .Flags("layer_apply")).BuildImageTag("sample.jpg")
image with transformations applied to the overlay

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

Adding image underlays

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

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

Ruby:
cl_image_tag("smartphone.png", :transformation=>[
  {:height=>200, :width=>200, :crop=>"fill"},
  {:effect=>"brightness:100", :height=>200, :underlay=>"site_bg", :width=>200}
  ])
PHP:
cl_image_tag("smartphone.png", array("transformation"=>array(
  array("height"=>200, "width"=>200, "crop"=>"fill"),
  array("effect"=>"brightness:100", "height"=>200, "underlay"=>"site_bg", "width"=>200)
  )))
Python:
CloudinaryImage("smartphone.png").image(transformation=[
  {"height": 200, "width": 200, "crop": "fill"},
  {"effect": "brightness:100", "height": 200, "underlay": "site_bg", "width": 200}
  ])
Node.js:
cloudinary.image("smartphone.png", {transformation: [
  {height: 200, width: 200, crop: "fill"},
  {effect: "brightness:100", height: 200, underlay: "site_bg", width: 200}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .height(200).width(200).crop("fill").chain()
  .effect("brightness:100").height(200).underlay("site_bg").width(200)).imageTag("smartphone.png")
jQuery:
$.cloudinary.image("smartphone.png", {transformation: [
  {height: 200, width: 200, crop: "fill"},
  {effect: "brightness:100", height: 200, underlay: "site_bg", width: 200}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Height(200).Width(200).Crop("fill").Chain()
  .Effect("brightness:100").Height(200).Underlay("site_bg").Width(200)).BuildImageTag("smartphone.png")
Image with underlay

Adding text captions

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

Ruby:
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500},
  {:overlay=>"text:Arial_80:Flowers"}
  ])
PHP:
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500),
  array("overlay"=>"text:Arial_80:Flowers")
  )))
Python:
CloudinaryImage("flowers.jpg").image(transformation=[
  {"width": 500},
  {"overlay": "text:Arial_80:Flowers"}
  ])
Node.js:
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "text:Arial_80:Flowers"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(500).chain()
  .overlay("text:Arial_80:Flowers")).imageTag("flowers.jpg")
jQuery:
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "text:Arial_80:Flowers"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Chain()
  .Overlay("text:Arial_80:Flowers")).BuildImageTag("flowers.jpg")
Adding dynamic text to image

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

Possible styling parameters include:

  • font_family - Required name of a font family. e.g., arial
  • font_size - Required font size in pixels. e.g., 12
  • font_weight - Optional text weight. Possible values: normal (default value) or bold. e.g., bold
  • font_style - Optional font style. Possible values: normal (default value) or italic. e.g., italic
  • text_decoration - Optional text decoration. Possible values: none (default value), underline or strikethrough. e.g., underline
  • text_align - Optional text alignment. Possible values: left (default value), center, right, end, start or justify. e.g., justify
  • stroke - Optional font stroke (border). Possible values: none (default value) or stroke. e.g., stroke. Set the color and weight of the stroke with the border parameter (bo in URLs).
  • letter_spacing - Optional spacing between the letters in pixels. Can be a positive or negative, integer or decimal value. The parameter name must also be included with the value to differentiate it from the font size value. e.g., letter_spacing_3.3
  • line_spacing - Optional spacing between the lines in pixels (only relevant for multi-line text). Can be a positive or negative, integer or decimal value. The parameter name must also be included with the value to differentiate it from the font size value. e.g., line_spacing_2.8

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

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

Ruby:
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500},
  {:overlay=>"text:Verdana_75_bold_underline_letter_spacing_14:Flowers"}
  ])
PHP:
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500),
  array("overlay"=>"text:Verdana_75_bold_underline_letter_spacing_14:Flowers")
  )))
Python:
CloudinaryImage("flowers.jpg").image(transformation=[
  {"width": 500},
  {"overlay": "text:Verdana_75_bold_underline_letter_spacing_14:Flowers"}
  ])
Node.js:
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "text:Verdana_75_bold_underline_letter_spacing_14:Flowers"}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(500).chain()
  .overlay("text:Verdana_75_bold_underline_letter_spacing_14:Flowers")).imageTag("flowers.jpg")
jQuery:
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "text:Verdana_75_bold_underline_letter_spacing_14:Flowers"}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Chain()
  .Overlay("text:Verdana_75_bold_underline_letter_spacing_14:Flowers")).BuildImageTag("flowers.jpg")
Adding text to image

As for displaying image overlays, you can also determine the dimension and position of the text caption using the width, height, x, y and gravity parameters. The resulting caption is actually an image created on the fly and can be further manipulated like any other image uploaded to Cloudinary.

For example, adding the text string "Cool image" in Roboto font with a size of 60 pixels at a distance of 80 pixels from the bottom of the image named flowers:

Ruby:
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500},
  {:overlay=>"text:Roboto_60:Cool%20image", :gravity=>"south", :y=>80}
  ])
PHP:
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500),
  array("overlay"=>"text:Roboto_60:Cool%20image", "gravity"=>"south", "y"=>80)
  )))
Python:
CloudinaryImage("flowers.jpg").image(transformation=[
  {"width": 500},
  {"overlay": "text:Roboto_60:Cool%20image", "gravity": "south", "y": 80}
  ])
Node.js:
cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "text:Roboto_60:Cool%20image", gravity: "south", y: 80}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .width(500).chain()
  .overlay("text:Roboto_60:Cool%20image").gravity("south").y(80)).imageTag("flowers.jpg")
jQuery:
$.cloudinary.image("flowers.jpg", {transformation: [
  {width: 500},
  {overlay: "text:Roboto_60:Cool%20image", gravity: "south", y: 80}
  ]})
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Width(500).Chain()
  .Overlay("text:Roboto_60:Cool%20image").Gravity("south").Y(80)).BuildImageTag("flowers.jpg")
Cool image text added to image

Set text color

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

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

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

Ruby:
cl_image_tag("flowers.jpg", :transformation=>[
  {:width=>500},
  {:overlay=>"text:Times_90_bold:Cool%20image", :gravity=>"south", :y=>80, :color=>"#FFFF00"}
  ])
PHP:
cl_image_tag("flowers.jpg", array("transformation"=>array(
  array("width"=>500),
  array("overlay"=>"text:Times_90_bold:Cool%20image", "gravity"=>"south", "y"=>80, "color"=>"#FFFF00")
  )))
Python:
CloudinaryImage("flowers.jpg").image(transformation=[
  {"width": 500},
  {"overlay": "text:Times_90_bold:Cool%20image&