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

 Lazy-Load React to Enhance Page Performance for Your Apps

React is a popular open-source JavaScript library for creating user interfaces (UIs) for single-page web applications, with React Native slated for building mobile apps. Helpfully, React organizes UIs into collections of reusable components, rendering feature management a cakewalk. However, to boost user engagement, conversion, and SEO ranking, you must optimize your app for fast page loads.

Read more
The Hub Helps Creative Talent Win Brand Work with Cloudinary

The Hub is decentralizing the creative process through its two-sided online marketplace that changes the way brands hire creators. The old model of committing all creative resources to one agency of record has proven time-consuming and expensive. Additionally, brands are limited to content that is only as good as the handful of people on that agency’s team.

Read more
A Primer on Microbrowsers

How we browse online in our quest of information has largely been an unknown factor since the Internet became ubiquitous in the mid-1990s. What’s indisputable is that we’re unlikely to type in URLs as a start, especially if we don’t have clues as to which site to visit. Google search revolutionized the ability to find relevant information through keyword entries, leading to the emergence of search-engine optimization (SEO), whereby you as site owners ensure that the popular keywords appear in your content.

Read more
Top 5 Reasons for Attending ImageCon 2020: A Digital Experience

ImageCon, Cloudinary’s annual conference on innovating the Visual Web, will be held digitally between July 27-30 with an agenda that outdoes the past years’, featuring presentations by developers, creatives, and marketing professionals across the globe. Not only will you learn the latest groundbreaking technologies, strategies, and best practices for media management, you’ll also have many opportunities to interact with our speakers and ask them questions live during the live Q&A sessions.

Read more
AI-based Automatic Image Cropping for E-Commerce

If you’ve come across this post and, based on the title, are expecting insights into object-oriented programming languages, then please forgive me for overloading the term object-oriented. I hope you don’t object when you discover that the objects in this post are not so much the instantiated class types, but real-life objects found in images. It is helpful though if you’re familiar with the likes of Java, PHP, Javascript or other popular frameworks, as you’ll be able to implement these automatic image cropping techniques in your code. Anyway, let’s cut to the chase - or should that be crop to the object...?

Read more