Cloudinary Blog

Applying Your Own Duotone Effect Filter With Cloudinary

Applying Your Own Duotone Effect Filter With Cloudinary

The trendy duotone effect is ubiquitous in today’s websites and illustrations for good reason: it highlights content well, rendering it pleasing to the eye, especially on minimal web platforms. The sky is the limit as to how much you can play with colors while applying a duotone effect. You could keep trying them out until something stands out.

Here are two images with a duotone effect applied from design tools, such as Adobe’s Photoshop and Illustrator:

Duotone Spotify Source: adobedownload.org

Duotone Source: Adobe

The Cloudinary process is a lot simpler and faster, however. Read on for the details.

Webinar
Top ten image and video mistakes

Do It the Simple and Fast Way With Cloudinary

To apply duotone to an image with Cloudinary:

  1. Upload to Cloudinary the image, for example, the one below. Original

  2. Add the e_grayscale and e_tint parameters to the image URL, which then reads:

    Ruby:
    Copy to clipboard
    cl_image_tag("fashion_woman.jpg", :transformation=>[
      {:effect=>"grayscale"},
      {:effect=>"tint"}
      ])
    PHP:
    Copy to clipboard
    cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
      array("effect"=>"grayscale"),
      array("effect"=>"tint")
      )))
    Python:
    Copy to clipboard
    CloudinaryImage("fashion_woman.jpg").image(transformation=[
      {'effect': "grayscale"},
      {'effect': "tint"}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("fashion_woman.jpg", {transformation: [
      {effect: "grayscale"},
      {effect: "tint"}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .effect("grayscale").chain()
      .effect("tint")).imageTag("fashion_woman.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('fashion_woman.jpg', {transformation: [
      {effect: "grayscale"},
      {effect: "tint"}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("fashion_woman.jpg", {transformation: [
      {effect: "grayscale"},
      {effect: "tint"}
      ]})
    React:
    Copy to clipboard
    <Image publicId="fashion_woman.jpg" >
      <Transformation effect="grayscale" />
      <Transformation effect="tint" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image publicId="fashion_woman.jpg" >
      <cld-transformation effect="grayscale" />
      <cld-transformation effect="tint" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="fashion_woman.jpg" >
      <cl-transformation effect="grayscale">
      </cl-transformation>
      <cl-transformation effect="tint">
      </cl-transformation>
    </cl-image>
    .Net:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Effect("grayscale").Chain()
      .Effect("tint")).BuildImageTag("fashion_woman.jpg")
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .effect("grayscale").chain()
      .effect("tint")).generate("fashion_woman.jpg");
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setEffect("grayscale").chain()
      .setEffect("tint")).generate("fashion_woman.jpg")!, cloudinary: cloudinary)
    Tint

  3. Assign a numerical value, e.g., 50, to e_tint. The URL then reads:

    Ruby:
    Copy to clipboard
    cl_image_tag("fashion_woman.jpg", :transformation=>[
      {:effect=>"grayscale"},
      {:effect=>"tint:50"}
      ])
    PHP:
    Copy to clipboard
    cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
      array("effect"=>"grayscale"),
      array("effect"=>"tint:50")
      )))
    Python:
    Copy to clipboard
    CloudinaryImage("fashion_woman.jpg").image(transformation=[
      {'effect': "grayscale"},
      {'effect': "tint:50"}
      ])
    Node.js:
    Copy to clipboard
    cloudinary.image("fashion_woman.jpg", {transformation: [
      {effect: "grayscale"},
      {effect: "tint:50"}
      ]})
    Java:
    Copy to clipboard
    cloudinary.url().transformation(new Transformation()
      .effect("grayscale").chain()
      .effect("tint:50")).imageTag("fashion_woman.jpg");
    JS:
    Copy to clipboard
    cloudinary.imageTag('fashion_woman.jpg', {transformation: [
      {effect: "grayscale"},
      {effect: "tint:50"}
      ]}).toHtml();
    jQuery:
    Copy to clipboard
    $.cloudinary.image("fashion_woman.jpg", {transformation: [
      {effect: "grayscale"},
      {effect: "tint:50"}
      ]})
    React:
    Copy to clipboard
    <Image publicId="fashion_woman.jpg" >
      <Transformation effect="grayscale" />
      <Transformation effect="tint:50" />
    </Image>
    Vue.js:
    Copy to clipboard
    <cld-image publicId="fashion_woman.jpg" >
      <cld-transformation effect="grayscale" />
      <cld-transformation effect="tint:50" />
    </cld-image>
    Angular:
    Copy to clipboard
    <cl-image public-id="fashion_woman.jpg" >
      <cl-transformation effect="grayscale">
      </cl-transformation>
      <cl-transformation effect="tint:50">
      </cl-transformation>
    </cl-image>
    .Net:
    Copy to clipboard
    cloudinary.Api.UrlImgUp.Transform(new Transformation()
      .Effect("grayscale").Chain()
      .Effect("tint:50")).BuildImageTag("fashion_woman.jpg")
    Android:
    Copy to clipboard
    MediaManager.get().url().transformation(new Transformation()
      .effect("grayscale").chain()
      .effect("tint:50")).generate("fashion_woman.jpg");
    iOS:
    Copy to clipboard
    imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
      .setEffect("grayscale").chain()
      .setEffect("tint:50")).generate("fashion_woman.jpg")!, cloudinary: cloudinary)
    Tint

The bigger the number, the stronger the effect.

Change Color With Only a Few Keystrokes

By default, the duotone color is red. For a different color, specify it in e_tint, for example blue:

Ruby:
Copy to clipboard
cl_image_tag("fashion_woman.jpg", :transformation=>[
  {:effect=>"grayscale"},
  {:effect=>"tint:50:blue"}
  ])
PHP:
Copy to clipboard
cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
  array("effect"=>"grayscale"),
  array("effect"=>"tint:50:blue")
  )))
Python:
Copy to clipboard
CloudinaryImage("fashion_woman.jpg").image(transformation=[
  {'effect': "grayscale"},
  {'effect': "tint:50:blue"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("fashion_woman.jpg", {transformation: [
  {effect: "grayscale"},
  {effect: "tint:50:blue"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .effect("grayscale").chain()
  .effect("tint:50:blue")).imageTag("fashion_woman.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('fashion_woman.jpg', {transformation: [
  {effect: "grayscale"},
  {effect: "tint:50:blue"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("fashion_woman.jpg", {transformation: [
  {effect: "grayscale"},
  {effect: "tint:50:blue"}
  ]})
React:
Copy to clipboard
<Image publicId="fashion_woman.jpg" >
  <Transformation effect="grayscale" />
  <Transformation effect="tint:50:blue" />
</Image>
Vue.js:
Copy to clipboard
<cld-image publicId="fashion_woman.jpg" >
  <cld-transformation effect="grayscale" />
  <cld-transformation effect="tint:50:blue" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="fashion_woman.jpg" >
  <cl-transformation effect="grayscale">
  </cl-transformation>
  <cl-transformation effect="tint:50:blue">
  </cl-transformation>
</cl-image>
.Net:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Effect("grayscale").Chain()
  .Effect("tint:50:blue")).BuildImageTag("fashion_woman.jpg")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .effect("grayscale").chain()
  .effect("tint:50:blue")).generate("fashion_woman.jpg");
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setEffect("grayscale").chain()
  .setEffect("tint:50:blue")).generate("fashion_woman.jpg")!, cloudinary: cloudinary)
Tint

Mix Colors

You can mix colors, for example, add yellow to blue in e_tint. The URL then reads:

Ruby:
Copy to clipboard
cl_image_tag("fashion_woman.jpg", :transformation=>[
  {:effect=>"grayscale"},
  {:effect=>"tint:50:blue:yellow"}
  ])
PHP:
Copy to clipboard
cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
  array("effect"=>"grayscale"),
  array("effect"=>"tint:50:blue:yellow")
  )))
Python:
Copy to clipboard
CloudinaryImage("fashion_woman.jpg").image(transformation=[
  {'effect': "grayscale"},
  {'effect': "tint:50:blue:yellow"}
  ])
Node.js:
Copy to clipboard
cloudinary.image("fashion_woman.jpg", {transformation: [
  {effect: "grayscale"},
  {effect: "tint:50:blue:yellow"}
  ]})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation()
  .effect("grayscale").chain()
  .effect("tint:50:blue:yellow")).imageTag("fashion_woman.jpg");
JS:
Copy to clipboard
cloudinary.imageTag('fashion_woman.jpg', {transformation: [
  {effect: "grayscale"},
  {effect: "tint:50:blue:yellow"}
  ]}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("fashion_woman.jpg", {transformation: [
  {effect: "grayscale"},
  {effect: "tint:50:blue:yellow"}
  ]})
React:
Copy to clipboard
<Image publicId="fashion_woman.jpg" >
  <Transformation effect="grayscale" />
  <Transformation effect="tint:50:blue:yellow" />
</Image>
Vue.js:
Copy to clipboard
<cld-image publicId="fashion_woman.jpg" >
  <cld-transformation effect="grayscale" />
  <cld-transformation effect="tint:50:blue:yellow" />
</cld-image>
Angular:
Copy to clipboard
<cl-image public-id="fashion_woman.jpg" >
  <cl-transformation effect="grayscale">
  </cl-transformation>
  <cl-transformation effect="tint:50:blue:yellow">
  </cl-transformation>
</cl-image>
.Net:
Copy to clipboard
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Effect("grayscale").Chain()
  .Effect("tint:50:blue:yellow")).BuildImageTag("fashion_woman.jpg")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation()
  .effect("grayscale").chain()
  .effect("tint:50:blue:yellow")).generate("fashion_woman.jpg");
iOS:
Copy to clipboard
imageView.cldSetImage(cloudinary.createUrl().setTransformation(CLDTransformation()
  .setEffect("grayscale").chain()
  .setEffect("tint:50:blue:yellow")).generate("fashion_woman.jpg")!, cloudinary: cloudinary)
Tint

Feel free to experiment further with other colors.

Read the Reference Documentation

For the syntax of applying various duotone effects along with examples, check out this API reference and cookbook.

About Cloudinary

Cloudinary provides easy-to-use, cloud-based media management solutions for the world’s top brands. With offices in the US, UK and Israel, Cloudinary has quickly become the de facto solution used by developers and marketers at major companies around the world to streamline rich media management and deliver optimal end-user experiences.

For more information, visit www.cloudinary.com or follow us on Twitter

Recent Blog Posts

Automation Frees Up PetRescue’s Staff to Help Pets Find Their Forever Homes

As we spend more time at home, many of us are adopting pets for the joy, companionship and a surprising range of health benefits. In Australia, where our nonprofit customer PetRescue is located, there’s a shortage of pets to adopt. Last August, the Guardian reported that dog shelters in Australia emptied and adoption fees for puppies were running as high as $AUS1800.

Read more
Cloudinary and Contentful Make Modern Content Management Easier

I am pleased to share that Cloudinary and Contentful have joined forces to further streamline the creation, processing, and delivery of online content through Cloudinary’s digital asset management (DAM) solution and advanced transformation and delivery capabilities for images and video. What’s more, the partnership delivers a headless approach to DAM. By leveraging APIs for media management tasks, marketers and developers alike benefit from an integrated stack of optimized assets for optimization and automation. As a result, page loads are fast and beautiful, and at scale—with less overhead and effort.

Read more
Introducing Cloudinary's Nuxt Module

Since its initial release in October 2016 by the Chopin brothers as a server-side framework that runs on top of Vue.js, Nuxt (aka Nuxt.js) has gained prominence in both intuitiveness and performance. The framework offers numerous built-in features based on a modular architecture, bringing ease and simplicity to web development. Not surprisingly, Nuxt.js has seen remarkable growth in adoption by the developer community along with accolades galore. At this writing, Nuxt has earned over 30K stars on GitHub and 96 active modules with over a million downloads per month. And the upward trend is ongoing.

Read more
How Quality and Quantity can go Hand in Hand

When it comes to quality versus quantity, you’ll often hear people say, “It’s the quality that counts, not the quantity”. While that’s true in many situations, there are also cases where you want both quality and quantity. You may have thousands of images on your website and you want them all to look great. This is especially important if your website allows users to upload their own content, for example, to sell their own products or services. You don't want their poor quality images to reflect badly on your brand.

Read more
Product Videos 101: What Makes Them Great?

A product’s benefits and usage, including its value proposition, features, and instructive details, are best demonstrated through video. Product-video types vary, depending on the funnel, channel, and audience, the most popular ones being demos, reviews, installation, and how-tos.

Read more