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 v1:
    Copy to clipboard
    cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
      array("effect"=>"grayscale"),
      array("effect"=>"tint")
      )))
    PHP v2:
    Copy to clipboard
    (new ImageTag('fashion_woman.jpg'))
      ->effect(Effect::grayscale())
      ->adjust(Adjust::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 v1:
    Copy to clipboard
    cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
      array("effect"=>"grayscale"),
      array("effect"=>"tint:50")
      )))
    PHP v2:
    Copy to clipboard
    (new ImageTag('fashion_woman.jpg'))
      ->effect(Effect::grayscale())
      ->adjust(Adjust::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 v1:
Copy to clipboard
cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
  array("effect"=>"grayscale"),
  array("effect"=>"tint:50:blue")
  )))
PHP v2:
Copy to clipboard
(new ImageTag('fashion_woman.jpg'))
  ->effect(Effect::grayscale())
  ->adjust(Adjust::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 v1:
Copy to clipboard
cl_image_tag("fashion_woman.jpg", array("transformation"=>array(
  array("effect"=>"grayscale"),
  array("effect"=>"tint:50:blue:yellow")
  )))
PHP v2:
Copy to clipboard
(new ImageTag('fashion_woman.jpg'))
  ->effect(Effect::grayscale())
  ->adjust(Adjust::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

Why the Future of E-commerce Is Live

In a previous post, I discussed how “going live” is gaining popularity across industries and verticals. What began as a way for gamers to jam together has evolved into a medium for broader entertainment and business purposes. To continue the conversation, this post unpacks the current trends of shoppable live streams to shine a light on how brands are leveraging “lives” to connect with shoppers in new ways.

Read more
An Overview of Live-Streaming Video Trends

“Let’s go live.” For decades, that’s what newscasters say as they cut to real-time footage of a colleague reporting in the field. The live-video feed adds visual interest and perspective to a story beyond what can be communicated by someone sitting behind the news desk. In the same way, live-streaming video nowadays adds context to other consumer environments. From gaming and events to shopping and social media, “going live” enhances everyday experiences, and it’s something anyone can do with relative ease.

Read more
Readying Live Streams for Video on Demand

When planning a live broadcast or stream, companies often overlook the redistribution phase, but live-stream videos are useful well beyond their initial streaming. Why? Because not everyone watches the first run. For a wider audience, it makes sense to repost live content on your website under an “events” tab, on YouTube, and other social sites for video on demand (VOD). However, preparing footage for reposting can be a lot of work.

Read more
Optimize Visual Media for a Fast and Captivating Digital Experience

Did you know that humans process imagery 60,000 times faster than text? In fact, 90% of the information our brains process is visual, which makes it seem a no-brainer—pun intended—that brands are connecting with consumers through visual content online. However, adding media assets like images and videos to websites comes with a tradeoff: the more media, the heavier the site, which results in a noticeable slowdown in page loads and a reduction in content quality.

Read more