Cloudinary Blog

Help users 'toon' into your site with a cartoon effect

Increase engagement with on-the-fly cartoon effect

We all know that images attract interest and increase engagement, but with the huge overload of images out there, we sometimes need to get creative to stand out in the crowd. Your users who upload photos to your site or app may also be looking for those same creative opportunities. A quick look at the most popular social media apps and their continually increasing toolbox of special photo effects shows the increasing trend in popularity and demand for these fun ways of expressing one’s identity.

Cartoonifying a photo is one great way to accomplish this.

Graphic designers can manually apply a cartoon effect to photos using a combination of features in sophisticated graphics applications. There are also a variety of online applications where you can upload a photo and get a cartoon version (of varying quality) returned. But these manual methods don’t scale if you have many photos where you want to apply this effect. And offering this feature to your users for the content they upload to your site requires a complex algorithm.

In short, you need a simple way to apply cartoon effects programmatically.

Cloudinary’s image management solution includes a broad set of cloud-based image manipulation capabilities. The manipulation takes place on-the-fly when the dynamic image URLs are first accessed, and then they are immediately cached on CDN servers for even faster delivery.

The new cartoonify effect is yet another way that Cloudinary enables its customers to quickly, easily, and optimally deliver transformed photos that have just the right impact. With a single parameter and a couple optional attributes, you can give any image a unique cartoonified look and feel.

How does it work?

For a default cartoonify effect, it couldn’t be simpler! Just add the cartoonify parameter (e_cartoonify) to your image tag definition, and the original image gets cartoonified and delivered on-the-fly. Of-course you can also combine this cartoon effect with any other transformation your heart desires.

Original Original Cartoonified Cartoonified Cartoon and other transformations Cartoon and
other transformations

Here’s the transformation code for that last image, which takes advantage of the text overlay, placement gravity, radius, outline, and background color features, in addition to cartoonify:

Ruby:
cl_image_tag("actor.jpg", :transformation=>[
  {:effect=>"cartoonify"},
  {:radius=>"max"},
  {:effect=>"outline:100", :color=>"lightblue"},
  {:background=>"lightblue"},
  {:overlay=>"text:times_120:James%20Stewart", :gravity=>"south_east", :y=>30, :angle=>315}
  ])
PHP:
cl_image_tag("actor.jpg", array("transformation"=>array(
  array("effect"=>"cartoonify"),
  array("radius"=>"max"),
  array("effect"=>"outline:100", "color"=>"lightblue"),
  array("background"=>"lightblue"),
  array("overlay"=>"text:times_120:James%20Stewart", "gravity"=>"south_east", "y"=>30, "angle"=>315)
  )))
Python:
CloudinaryImage("actor.jpg").image(transformation=[
  {"effect": "cartoonify"},
  {"radius": "max"},
  {"effect": "outline:100", "color": "lightblue"},
  {"background": "lightblue"},
  {"overlay": "text:times_120:James%20Stewart", "gravity": "south_east", "y": 30, "angle": 315}
  ])
Node.js:
cloudinary.image("actor.jpg", {transformation: [
  {effect: "cartoonify"},
  {radius: "max"},
  {effect: "outline:100", color: "lightblue"},
  {background: "lightblue"},
  {overlay: "text:times_120:James%20Stewart", gravity: "south_east", y: 30, angle: 315}
  ]})
Java:
cloudinary.url().transformation(new Transformation()
  .effect("cartoonify").chain()
  .radius("max").chain()
  .effect("outline:100").color("lightblue").chain()
  .background("lightblue").chain()
  .overlay("text:times_120:James%20Stewart").gravity("south_east").y(30).angle(315)).imageTag("actor.jpg")
JS:
cl.imageTag('actor.jpg', {transformation: [
  {effect: "cartoonify"},
  {radius: "max"},
  {effect: "outline:100", color: "lightblue"},
  {background: "lightblue"},
  {overlay: "text:times_120:James%20Stewart", gravity: "south_east", y: 30, angle: 315}
  ]}).toHtml();
jQuery:
$.cloudinary.image("actor.jpg", {transformation: [
  {effect: "cartoonify"},
  {radius: "max"},
  {effect: "outline:100", color: "lightblue"},
  {background: "lightblue"},
  {overlay: "text:times_120:James%20Stewart", gravity: "south_east", y: 30, angle: 315}
  ]})
React:
<Image publicId="actor.jpg" >
  <Transformation effect="cartoonify" />
  <Transformation radius="max" />
  <Transformation effect="outline:100" color="lightblue" />
  <Transformation background="lightblue" />
  <Transformation overlay="text:times_120:James%20Stewart" gravity="south_east" y="30" angle="315" />
</Image>
Angular:
<cl-image public-id="actor.jpg" >
  <cl-transformation effect="cartoonify">
  </cl-transformation>
  <cl-transformation radius="max">
  </cl-transformation>
  <cl-transformation effect="outline:100" color="lightblue">
  </cl-transformation>
  <cl-transformation background="lightblue">
  </cl-transformation>
  <cl-transformation overlay="text:times_120:James%20Stewart" gravity="south_east" y="30" angle="315">
  </cl-transformation>
</cl-image>
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation()
  .Effect("cartoonify").Chain()
  .Radius("max").Chain()
  .Effect("outline:100").Color("lightblue").Chain()
  .Background("lightblue").Chain()
  .Overlay("text:times_120:James%20Stewart").Gravity("south_east").Y(30).Angle(315)).BuildImageTag("actor.jpg")
Android:
MediaManager.get().url().transformation(new Transformation()
  .effect("cartoonify").chain()
  .radius("max").chain()
  .effect("outline:100").color("lightblue").chain()
  .background("lightblue").chain()
  .overlay("text:times_120:James%20Stewart").gravity("south_east").y(30).angle(315)).generate("actor.jpg")

For more details on all the available transformations, see the image transformation guide and reference.

For added control on your cartoonified image, you can adjust the line strength of the black outlines and the color reduction impact. (As you increase the color_reduction value, and thus decrease the number of colors in the image, the image also gets a higher saturation boost, and a few other adjustments, all leading to a less realistic look).

For example, the following images show the original image, compared to cartoonified versions with different adjustments in line strength and color reduction.

Original Original

Above average line thickness, below average color reduction Above average line thickness, below average color reduction

Below average line thickness, above average color reduction Below average line thickness, above average color reduction

And here’s what your code would look like for the last cartoonified car:

Ruby:
cl_image_tag("alfa_car.jpg", :effect=>"cartoonify:30:80")
PHP:
cl_image_tag("alfa_car.jpg", array("effect"=>"cartoonify:30:80"))
Python:
CloudinaryImage("alfa_car.jpg").image(effect="cartoonify:30:80")
Node.js:
cloudinary.image("alfa_car.jpg", {effect: "cartoonify:30:80"})
Java:
cloudinary.url().transformation(new Transformation().effect("cartoonify:30:80")).imageTag("alfa_car.jpg")
JS:
cl.imageTag('alfa_car.jpg', {effect: "cartoonify:30:80"}).toHtml();
jQuery:
$.cloudinary.image("alfa_car.jpg", {effect: "cartoonify:30:80"})
React:
<Image publicId="alfa_car.jpg" >
  <Transformation effect="cartoonify:30:80" />
</Image>
Angular:
<cl-image public-id="alfa_car.jpg" >
  <cl-transformation effect="cartoonify:30:80">
  </cl-transformation>
</cl-image>
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("cartoonify:30:80")).BuildImageTag("alfa_car.jpg")
Android:
MediaManager.get().url().transformation(new Transformation().effect("cartoonify:30:80")).generate("alfa_car.jpg")

Oh, and you can also choose to generate a black and white cartoon if that suits your fancy.

Original Above average line thickness, below average color reduction

Ruby:
cl_image_tag("boy_tree.jpg", :effect=>"cartoonify:50:bw")
PHP:
cl_image_tag("boy_tree.jpg", array("effect"=>"cartoonify:50:bw"))
Python:
CloudinaryImage("boy_tree.jpg").image(effect="cartoonify:50:bw")
Node.js:
cloudinary.image("boy_tree.jpg", {effect: "cartoonify:50:bw"})
Java:
cloudinary.url().transformation(new Transformation().effect("cartoonify:50:bw")).imageTag("boy_tree.jpg")
JS:
cl.imageTag('boy_tree.jpg', {effect: "cartoonify:50:bw"}).toHtml();
jQuery:
$.cloudinary.image("boy_tree.jpg", {effect: "cartoonify:50:bw"})
React:
<Image publicId="boy_tree.jpg" >
  <Transformation effect="cartoonify:50:bw" />
</Image>
Angular:
<cl-image public-id="boy_tree.jpg" >
  <cl-transformation effect="cartoonify:50:bw">
  </cl-transformation>
</cl-image>
.Net:
cloudinary.Api.UrlImgUp.Transform(new Transformation().Effect("cartoonify:50:bw")).BuildImageTag("boy_tree.jpg")
Android:
MediaManager.get().url().transformation(new Transformation().effect("cartoonify:50:bw")).generate("boy_tree.jpg")

Details for all of the above can be found in the effect parameter section of the image transformation reference.

Your turn to toon

Looks like fun, doesn’t it? Want to try it yourself?

Click one of the images below or    Upload an image

Adjust line strength: APPLY     Adjust color reduction: APPLY
* Enter values between 1-100. For black and white, enter 'bw' in color reduction.    

Th...th...th...that’s all folks!

Yes, it’s that simple: one parameter added to your delivery URL or passed on as an option to your users when they upload their profile pics or other images, and the required cartoonification algorithms are automatically applied to the photo.

And don’t forget that cartoon-like images are more than just another cool effect. Cartoonified images can help capture an audience, and they may be more memorable to your users among the plethora of regular photos in every web page on the net.

Additionally, when used in the appropriate context, cartoonified images may be able to express an intended tone, emotion, or personality better than the original photo. And according to marketing consultant, Marcia Hoeck, emotion is (not surprisingly) better at triggering the circuits in the brain that activate behavior and decisions than logic is.

You now know how simple it can be to programmatically cartoonify any image with Cloudinary. And you can do it with any Cloudinary account, including a free one.

So the next time you are looking for just the right creative image that will get your users to tune into your message, consider 'tooning it.

Recent Blog Posts

How the Right Tools and Training Drive SDR Success

Here at Cloudinary, I head a team of eight SDRs, who are responsible for creating the first impression potential customers have of our company’s brand. In just the first 10 months of 2017, our team of outbound SDRs have been responsible for sending more than 67,000 personalized emails and making more than 15,000 calls.

Read more
The JS video player that developers will love (How To)

It doesn't take a genius (or a statistician) to know that video represents a significant proportion of web and mobile content these days. But did you realize that in 2017, video will account for about 75% of all internet traffic and that 55% of people watch videos online every day? In fact, 52% of marketing professionals worldwide believe that video is the content type with the best ROI, with people spending up to 2.6x more time on pages with video than on those without.

Read more
 Beyond Drupal Media: Make Images and Video Fly with Cloudinary

Drupal is a very popular open source content management system (CMS) that has been deployed countless times by organizations and developers around the world. Drupal gained a reputation for being very flexible, powerful and robust in creating complex websites. With Drupal, you can create everything from plain websites, blogs and forums to ambitious enterprise systems.

Read more
Curbing Terrorist Content Online

Today, Cloudinary is proud to announce that it has joined The Global Internet Forum to Counter Terrorism (GIFCT), to help fight the spread of terrorist and violent extremist content on the Internet. The forum was established by Facebook, Microsoft, Twitter and YouTube in mid-2017. Cloudinary will contribute to the hash-sharing database, which all contributing companies can use to help identify and block terrorist related images and videos upon upload.

Read more
Introducing the complete video solution for developers

Videos in web sites and apps are starting to catch up with images in terms of popularity and they are a constantly growing part of the media strategy for most organizations. This means bigger challenges for developers who need to handle these videos in their web sites and mobile apps. Cloudinary's mission is to solve all developer needs around image and video management. In this blog post, we are excited to introduce Cloudinary's complete cloud-based video management solution for developers.

Read more