MEDIA GUIDES / Image Effects

Automatically Make an Image a Cartoon

cartoon image

Cartoon images, a popular and beloved art form, leverage the inherent qualities of photographs. In the world of NFTs, cartoons can be traded as collectibles. This post will show you how to efficiently transform an image into a cartoon using Cloudinary.

In addition to Cloudinary, there are several AI-powered tools that offer unique ways to cartoonify images. For instance, Cartoonify leverages AI to turn images into hand-drawn cartoons with extensive personalization options, including a vast selection of graphic parts for avatar customization. Similarly, MyEdit provides a straightforward process where users can upload an image, select a cartoon filter, and download the cartoonized version. These tools emphasize ease of use and accessibility, catering to users who prefer simpler methods without the need for technical knowledge.

When to make an image a cartoon

Numerous tools allow you to upload a photo and receive a cartoon version, but these have varied quality. What’s more, the techniques are manual and not scalable. Providing users with this feature requires a sophisticated algorithm. To programmatically apply cartoon effects, you need a simple method.

Adding Cartoonify effect at scale

Cloudinary is a comprehensive media management platform for websites and applications, allowing you to effortlessly enhance and apply effects to your images and videos. It offers a broad array of cloud-based image manipulations. When dynamic image URLs are accessed, transformations are applied instantly and cached on CDN servers for fast delivery.

Cloudinary effectively delivers images with a cartoon effect (called “Cartoonify”) with just one parameter and a few optional characteristics. Let’s see it in action!

Other popular options for creating cartoon images include BeFunky, an online photo editor offering a cartoonizer tool and various art effects, and CartoonifyMe, which focuses on transforming people into distinct cartoon characters.

Creating an app to add Cartoonify effect to your images

To Cartoonify your images, you’ll need to create a React app. If you don’t have Node JS installed, go to the official Node JS page and download the latest version.

Next, create a sample directory for your project. Open up a terminal, navigate to your project directory, and create a React app using the following npx command:

create a React app using the following npx command

This will create a sample project in your project directory with a pre-built code (you don’t need to worry about the complex code structure as it’s not needed for the app).

“Image

Step 1: Signing up to Cloudinary

Now that we’ve created our app, we need to set it up in order to Cartoonify with Cloudinary. You can create a free account here.

Install Cloudinary’s JavaScript and React packages using the NPM package manager:

npm i @cloudinary/url-gen @cloudinary/react

React packages using the NPM package manager

Then, navigate to your example-app directory and use npm start:

npm start

Step 2: Creating a React app

It’s time to start writing code for the React app. Go to your App.js file in the src directory and add the following code:

import './App.css';
import React from 'react'
import {Cloudinary} from "@cloudinary/url-gen";

const App = () => {

  // Create a Cloudinary instance and set your cloud name.
  const cld = new Cloudinary({
    cloud: {
      cloudName: 'demo'
    }
  });

};
export default App;

Here, a basic Cloudinary API is created that will help with image formatting. Set the couldName to demo (you can change this to your cloud name to use and format your assets).

Next, import the AdvancedImage module from Cloudinary to display our image:

import {AdvancedImage} from '@cloudinary/react';

Now, add the image to Cartoonify to the app. For our React app, we’ll use the cld-sample.jpg image that available in the demo cloud:

  const myImg =  cld.image("cld-sample.jpg");

Return the image:

  return (
    <div>
      <AdvancedImage cldImg={myImg} controls/>
    </div>
  )

Here is what the image looks like:

Sample image for the effect

Step 3: Applying the Cartoonify effect

We’re now ready to add the Cartoonify effect to the image.

First, import the Cartoonify effect from the effect module in Cloudinary:

import { cartoonify } from '@cloudinary/url-gen/actions/effect';

Next, apply the Cartoonify effect to the image by specifying it in the .effect() method:

  const myImg =  cld.image("cld-sample.jpg").effect(cartoonify());

Return the rendered image in a return statement.

Here is what the final code and output look like:

import './App.css';
import React from 'react'
import {Cloudinary} from "@cloudinary/url-gen";
import {AdvancedImage} from '@cloudinary/react';
import {cartoonify} from '@cloudinary/url-gen/actions/effect';

const App = () => {

  // Create a Cloudinary instance and set your cloud name.
  const cld = new Cloudinary({
    cloud: {
      cloudName: 'demo'
    }
  });
  const myImg =  cld.image("cld-sample.jpg").effect(cartoonify());

  return (
    <div>
      <AdvancedImage cldImg={myImg} controls/>
    </div>
  )

};
export default App;

Here is what the final image looks like with the Cartoonify effect applied:

Image with cartoonify automatically applied

Using the Cloudinary Console to Cartoonify your images

You can upload images via the API or using the Cloudinary Console. Learn more about uploading assets to Cloudinary in the Cloudinary Documentation.

To upload via the Cloudinary Console, login to your account. You’ll then be directed to the Dashboard. Click on the Transformations tab:

Console welcome

With Cloudinary, you can create custom and chain transformations, as well as custom effects. The Transformation tab is where you manage custom transformations and scale them to your images.

First, click on the blue Add New button to start creating your transformation:

Transformation builder to add cartoonify effect

Since the image we used previously was in the demo cloud, you’ll see it on your preview:

Image to apply cartoonify effect programatically

Next, click the Start Creating tab on the Transformation panel. Scroll down to the Advanced tab and click on Additional Transformations:

Automatic application to turn image into cartoon

By applying further transformations, you can generate dynamic URLs that allow for image creation programmatically, eliminating the need for graphic designers or advanced editing tools. Transformations can be specified by simply listing them. In the following example, we will apply the Cartoonify effect using the command below and then click Apply and Close:

e_cartoonify

Programatically turning image into cartoon

Save your transformation by clicking on the Save as Named Transformation button:

Saving transformation final image turned into cartoon

Conclusion

You now understand how easy it is to use Cloudinary to programmatically make an image a cartoon. We also demonstrated how to use the Cloudinary Console to accomplish this. All this is possible with a free Cloudinary account. In addition, Cloudinary offers SDKs (Software Development Kits) for backend, frontend, and mobile development. You can read about the SDKs available in the Cloudinary Documentation.

More from Cloudinary:

Automatically Generate Responsive Images
How to Handle Responsive Images in React
How to Resize an Image with React

QUICK TIPS
Colby Fayock
Cloudinary Logo Colby Fayock

In my experience, here are tips that can help you better implement the Cartoonify effect at scale using Cloudinary and achieve high-quality, visually engaging results:

  1. Fine-tune the Cartoonify parameters for better effects
    The basic cartoonify transformation works well for most images, but you can adjust additional parameters like line strength, color reduction, and granularity to create more sophisticated effects. Experiment with values like effect(cartoonify().lineStrength(70).colorReduction(80)) to produce custom cartoon styles suited to different image types.
  2. Use chained transformations for advanced image editing
    Combine cartoonify with other transformations, such as oilPaint or blur, to create unique art styles. For instance, applying a slight blur (effect(blur().strength(5))) before adding the cartoon effect can give a smoother, hand-drawn appearance. Chaining transformations helps you automate complex styles with a single API call.
  3. Utilize fetch URLs for remote image cartoonization
    If you need to apply the cartoon effect to images hosted on external URLs, use Cloudinary’s fetch URL feature. This allows you to dynamically pull in remote images and apply transformations without needing to upload them first, making it ideal for scenarios where the source images are stored elsewhere.
  4. Create responsive images with multiple cartoon variants
    Use Cloudinary’s responsive design tools to generate multiple cartoonized image versions optimized for different devices. By combining responsive_breakpoints with cartoonify, you ensure that images are always delivered in the optimal size and resolution, improving performance and visual quality on various screens.
  5. Pre-transform popular images to reduce processing load
    For high-traffic sites, consider using Cloudinary’s eager transformations to pre-transform frequently used images. By pre-processing popular assets, you reduce on-the-fly transformation costs and speed up delivery times, ensuring a seamless user experience when applying heavy effects like cartoonify.
  6. Leverage Cloudinary’s conditional transformations for selective effects
    Use Cloudinary’s conditional transformations to apply the cartoon effect only when certain conditions are met, such as image size or format. For example, apply the effect only to images larger than 1000px to ensure that high-quality images maintain their details, while small images remain unaltered.
  7. Implement version control for large-scale projects
    When managing large projects with numerous assets, use Cloudinary’s version control features to keep track of different cartoon styles and variations. Tagging different versions of cartoonized images allows you to roll back changes, test new styles, and manage your media assets more effectively.
  8. Use named transformations for consistent styling
    Create and store named transformations in the Cloudinary console for consistent cartoon styling across all projects. By defining named transformations like my_cartoon_style that include specific cartoonify parameters, you can reuse them easily across multiple projects, ensuring visual consistency without redefining parameters each time.
  9. Optimize for performance with format adjustments
    When applying the cartoon effect, deliver images in modern formats like WebP or AVIF, which provide better compression and faster load times. Adding .format('auto') at the end of your transformation string ensures that the best format is selected automatically based on the user’s browser and device.
  10. Automate batch cartoonification with Cloudinary’s API
    If you need to cartoonify thousands of images, use Cloudinary’s batch processing API. Automating the process through scripts helps you apply consistent effects at scale, ensuring that large collections of images can be processed quickly and efficiently without manual intervention.

By implementing these tips, you can leverage Cloudinary’s powerful capabilities to create cartoon-style images that are both visually stunning and optimized for performance, making it easier to scale up without sacrificing quality.

Last updated: Apr 11, 2025