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

Partner news: Cloudinary-Getty Images Integration

Supported by intelligent automation, Cloudinary serves as an effective conduit between media asset management and delivery so you can take maximum advantage of assets, compress workflows, and build and coordinate engaging and inspiring customer experiences. Through Cloudinary’s Digital Asset Management (DAM) solution, which employs the company’s innovative image and video APIs, creative and marketing teams can benefit from them, as well as from many AI-powered and automated capabilities. As a result, you can transform, optimize, and deliver media at scale on an intuitive UI.

Read more
Why Audio in Video Matters

Many content creators and consumers tend to regard video as visuals, but that’s only part of the experience. Immersive video content includes strong audio. Just like in a movie, the audio for video content comprises many components: the narrator or subjects, the background music that sets the mood and draws viewers in, sound effects, and so forth.

Read more

For Developers: the HTML <picture> Element Explained

By Amarachi Amaechi
For Developers: the HTML <picture> Element Explained

We all know the good ol', tireless <img> element, which has been a long-time go-to for inserting graphics into webpages. Time doesn’t stop, however, and neither do technological advancements. So, let’s get you up to speed with the element’s modern alternative: the <picture> element.

Read more