Cloudinary Blog

Applying Your Own Duotone Effect Filter With Cloudinary

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

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.

Recent Blog Posts

Our $2B Valuation

By
Blackstone Growth Invests in Cloudinary

When we started our journey in 2012, we were looking to improve our lives as developers by making it easier for us to handle the arduous tasks of handling images and videos in our code. That initial line of developer code has evolved into a full suite of media experience solutions driven by a mission that gradually revealed itself over the course of the past 10 years: help companies unleash the full potential of their media to create the most engaging visual experiences.

Read more
Direct-to-Consumer E-Commerce Requires Compelling Visual Experiences

When brands like you adopt a direct–to-consumer (DTC) e-commerce approach with no involvement of retailers or marketplaces, you gain direct and timely insight into evolving shopping behaviors. Accordingly, you can accommodate shoppers’ preferences by continually adjusting your product offering and interspersing the shopping journey with moments of excitement and intrigue. Opportunities abound for you to cultivate engaging customer relationships.

Read more
Automatically Translating Videos for an International Audience

No matter your business focus—public service, B2B integration, recruitment—multimedia, in particular video, is remarkably effective in communicating with the audience. Before, making video accessible to diverse viewers involved tasks galore, such as eliciting the service of production studios to manually dub, transcribe, and add subtitles. Those operations were costly and slow, especially for globally destined content.

Read more
Cloudinary Helps Minted Manage Its Image-Generation Pipeline at Scale

Shoppers return time and again to Minted’s global online community of independent artists and designers because they know they can count on unique, statement-making products of the highest quality there. Concurrently, the visual imagery on Minted.com must do justice to the designs into which the creators have poured their hearts and souls. For Minted’s VP of Engineering David Lien, “Because we are a premium brand, we need to ensure that every single one of our product images matches the selected configuration exactly. For example, if you pick an 18x24 art print on blue canvas, we will show that exact combination on the hero images in the PDF.”

Read more
Highlights on ImageCon 2021 and a Preview of ImageCon 2022

New year, same trend! Visual media will continue to play a monumental role in driving online conversions. To keep up with visual-experience trends and best practices, Cloudinary holds an annual conference called ImageCon, a one-of-a-kind event that helps attendees create the most engaging visual experiences possible.

Read more