Cloudinary Blog

Impressed by WhatsApp Tech? Build a Whatsapp Clone with Image Manipulation and Optimization

Build a WhatsApp Clone with Automatic Image Optimization

In the previous post, we showed how to upload images to a Cloudinary server. In this part, we will play with some of the features we see on the WhatsApp technology. After you or your users have uploaded image assets to Cloudinary, you can deliver them via dynamic URLs. You can include instructions in your dynamic URLs that tell Cloudinary to manipulate your assets using a set of transformation parameters. All image manipulations and image optimizations are performed automatically in the cloud and your transformed assets are automatically optimized before they are routed through a fast CDN to the end user for an optimal user experience. For example, you can resize and crop, add overlays, blur or pixelate faces, apply a variety of special effects and filters, and apply settings to optimize your images and to deliver them responsively.

Here are a few examples of the commonly used image transformation features, along with links to their more detailed documentation :

Resizing and Cropping :

We won’t be going in detail about all the listed features, as there are still a lot of them to be explored. However we’ve attached links to each of them should you decide to read further on your own. Now, with our MediaManager already initialized, we’ll quickly resize and crop our uploaded image in the onCreate() method. Here’s how :

MediaManager.get().url().transformation(new Transformation().width(250).height(250).gr

This example uses the fill cropping method to generate and deliver an image that completely fills the requested 250x250 size while retaining the original aspect ratio. It uses face detection gravity to ensure that all the faces in the image are retained and centered when the image is cropped

Applying Effects and Filters

WhatsApp technology doesn’t provide options like applying effects and filters just like Instagram. We can add this feature to our clone using Cloudinary:

MediaManager.get().url().transformation(new Transformation()

The code above applies a cartoonify effect, rounding corners effect, and background color effect (and then scales the image down to a height of 300 pixels).

There is a lot more you can do with Cloudinary image manipulations; you can even apply transformations based on certain conditions.

With Cloudinary’s conditional transformations, images are manipulated on-the-fly using dynamic delivery URLs for any uploaded image. A condition and its associated transformations are added to the URLs using the if parameter which accepts a string value detailing the condition to evaluate. You can apply a transformation based on the image's width, height, aspect ratio, the number of faces in the image (if any) or the number of frames (for animated images) or pages (for PDFs) present. For example, we can evaluate whether our uploaded image's width is greater than 500 pixels with if_w_gt_500. Also, multiple conditions can be evaluated by concatenating the conditions with an and or or operator, and a different transformation can be applied in the case that the condition is evaluated as negative by using the if_else parameter. Now let’s manipulate our uploaded image such that if it contains a face, we zoom into the face otherwise, we fit the entire image into the defined space.

Here’s how : Head back inside the onCreate() method in the MainActivity Class and define the transformations we just described using the MediaManager as thus :

// define transformation from MediaManager
MediaManager.get().url().transformation(new Transformation()
//if a face is detected
  //zoom into the face with the defined parameters
  //if a face is not detected, fit the image into the defined params
  //end transformation

Image Optimizations

By default, Cloudinary automatically performs certain optimizations on all transformed images. There are also a number of additional features that enable you to further optimize the images you use in your Android application. These include optimizations to image quality, format and size, among others. For example, you can use the auto value for the fetchFormat and quality attributes to automatically deliver the image in the format and quality that minimize file size while meeting the required quality level. Below, these two parameters are applied, resulting in a 50 percent file size reduction (1.4MB vs. 784KB) with no visible change in quality.

MediaManager.get().url().transformation(new Transformation().quality("auto").fetchForm

Convert image to another format

You can deliver any image uploaded to Cloudinary in essentially any image format. There are two major ways to convert and deliver in another format:

  • Specify the image's public ID with the desired extension.
  • Explicitly set the desired format using the fetchFormat parameter. Specifying the image's public ID with the desired extension is primarily the easiest way to convert it to another format. let’s take for example that we want to change the format of our uploaded image to a gif, we’ll simply specify it in the image delivery URL as thus :

Yeah, it’s that simple. We can also achieve the same result with the fetchFormat parameter. this is a bit trickier, but equally as simple.

MediaManager.get().url().transformation(new Transformation().width(350).crop("scale"))

All we had to do was set the desired format to be a gif.

Cloudinary Transformation and Delivery capabilities

Cloudinary enables you to easily transform your images on-the-fly to any required format, style and dimension, and also optimizes images to have the minimal file size for an improved user experience and for saving bandwidth. You can do this by implementing dynamic image transformation and delivery URLs for accessing the images. You can change the required transformations at any time and all transformed images will be created on-demand (lazily) and delivered to your users through a fast CDN with optimized caching.

Cloudinary's image management service supports the following image transformation and delivery capabilities:


Cloudinary is a cloud-based service that provides an end-to-end image and video management solution. The Android SDK provides simple, yet comprehensive file upload, administration, manipulation, optimization, and delivery capabilities. These can be implemented using code that integrates seamlessly with your existing Android application. You can leverage these awesome capabilities and deliver amazing media solutions to your subscribers and have them thank you later. DEMO

Recent Blog Posts

CoreMedia Adds Cloudinary to its CoreMedia Studio Platform

Today we’re pleased to announce a new technology partnership with CoreMedia, a leading Content Experience Platform provider. CoreMedia users can now leverage Cloudinary’s web-based digital asset management (DAM) solution to organize, search, manage and optimize their media assets, including images and videos, and to orchestrate, preview and deliver digital experiences consistently and optimized across all channels and browsers. The official press release is available here.

Read more
Facial-Surveillance System for Restricted Zones

In Africa, where Internet access and bandwidth are limited, it’s not cost-effective or feasible to establish and maintain a connectivity for security and surveillance applications. That challenge makes it almost impossible to build a service that detects, with facial-recognition technology, if someone entering a building is authorized to do so. To meet the final-year research requirement for my undergraduate studies, I developed a facial-surveillance system. Armed with a background in computer vision, I decided to push the limits and see if I could build a surveillance system that does not require recording long video footage.

Read more
Complex Networks Case Study

Complex Networks has been using Cloudinary since 2014 to manage and optimize images across seven websites and two mobile apps, making editorial workflow more efficient, improving page performance and load time, and increasing user engagement. Cloudinary was instrumental in enabling Complex Networks to redesign its web properties. Without the flexibility that Cloudinary offers to both creative and development teams, it would not have been possible for Complex Networks to achieve such a fast time to market.

Read more
Automate Placeholder Generation and Accelerate Page Loads

If you run a Google search on LQIP you’ll see very few relevant articles, very little guidance, and definitely no Wikipedia articles. In this post, we’ll discuss some of the feedback on LQIP we have gathered from the community and suggest and open for conversation a few approaches based on the built-in capabilities of the Cloudinary service. Specifically, we’ll explain what LQIP are, where they are best used, and how you can leverage them to accelerate page loads and optimize user experience.

Read more
Best Practices for Optimizing Web Page Speed

If you're like most consumers today, you engage more with pictures or videos on a website than text. The stats don't lie - four times as many visitors would rather watch a video about a product than read about it, and sites with compelling images average twice as many views as text-heavy ones.

Read more
A day of fun with Girls Who Code and Cloudinary

During both my computer science studies and work in the tech field, there have not been a lot of women present. While our ranks have grown, women still make up only a small percentage. In many ways, I think the traditionally male-dominated world can be intimidating to women and girls who may be interested in pursuing these types of tech careers.

Read more