Cloudinary Blog

Build a WhatsApp Clone with Automatic Image 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.

How to Optimize for Page Load Speed

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 :

Copy to clipboard
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:

Copy to clipboard
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 :

Copy to clipboard
// 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.

Copy to clipboard
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 :
Copy to clipboard

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.

Copy to clipboard
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

Laravel File Upload to a Local Server Or to the Cloud

Currently, Laravel is the most renowned PHP framework, boasting of a large developer community; several open-source packages, such as Cashier, Sanctum, Scout, and Telescope; and a host of paid platforms, e.g., Laravel Forge, Envoyer, and Vapor. Laravel Forge & Envoyer ably supports deployment and use of Laravel production-based apps.

Read more Automates Generation of Captivating Product Images on Cloudinary

At, we digitally restore historic maps and sell their art prints on multiple platforms, such as Amazon, Etsy, eBay, and Houzz. As our operations ramped up years ago, it took an inordinately long time to generate custom images for our products. Plus, since we sell art, it behooves us to produce multiple high-quality images for each print, which was another time-consuming task.

Read more Takes a Vacation From Media-Management Headaches With Cloudinary

As a 20-year online leader in travel and leisure retail, Europe-based public company along with its 1,200 employees are committed to enriching the lives of vacationers through comprehensive and enticing products and services. Beyond flight deals and tours, it's the images and videos, whether of that luxury villa in Greece, romantic Parisian street, or exotic stroll through the Marrakech markets, that attract audiences and boost bookings.

Read more