Cloudinary Blog

Face detection based cropping

by Nadav Soferman

Cloudinary’s roots go back to when we needed to embed users’ uploaded images and profile pictures for web projects we’ve developed.

We had to show people and faces of users in various dimensions and perspectives, and the process proved cumbersome.

These days, Cloudinary allows you to easily resize and crop your images to snugly fit the graphics design. But sometimes, just resizing pictures using ‘fill’ crop and ‘center’ gravity just doesn’t cut it. This is a common problem with user profile photos.


So we thought it is about time we add some more brainpower into the cropping process. Of-course we could just let the users manually crop their own profile pictures, but that just wasn’t fun enough :)

We decided to add face detection based cropping. Facebook use it internally to find faces of users and crop the profile pictures accordingly. Google does it as well. What about the rest of us?

Fortunately, we didn’t need to invent the wheel. Some top-notch face detection open source algorithms are freely available today. They are just not production ready or easy to integrate. The good news - we did the heavy lifting for you. We integrated existing tools and libraries, optimized their settings and added smart face detection based cropping to Cloudinary. Try it out - you won’t believe the difference that it makes.

Cloudinary supports either a single face detection or multiple faces detection (i.e., focusing on the people in a picture). You can easily create a face thumbnail of your users, crop an image to focus on a person or resize an image to fill the required dimensions while making sure the person in the original picture appears in the resized version of the image. And as usual, Cloudinary does all this automatically for you in the cloud and delivers the images through a fast CDN.



Using face detection based cropping with Cloudinary is very simple. Below are examples showing both cropping via our universal dynamic URLs and our Ruby on Rails integration.,h_100,c_thumb,g_face/face_top.jpg

<%= cl_image_tag("face_top.jpg", :width =>100, :height => 100,
:crop => :thumb, :gravity => :face) %>

For more details and usage examples, take a look at our documentation:

This feature is now available across all our plans, including the free one. We hope you like it.


Recent Blog Posts

Build A/B Testing & Personalization creative on the fly

Content Optimization and Personalization programs can deliver tremendous ROI to an organization but tend to be very resource intensive, requiring developers to build the code for alternate experiences and creative folks to generate the content. Many of the content optimization/personalization tools out there today (Maxymiser, Optimizely, Adobe Target, Ensighten etc.) have created WYSIWYG (What You See Is What You Get) editors to help relieve the code/development bottleneck but the creative bottleneck stubbornly remains.

Read more
Magento with enhanced media and image optimization

(Guest post by Grant Kemp)

Over the past few months Inviqa have been working to build an official plugin to simplify the process of adding Cloudinary to the 100,000s of Magento sites around the world. Inviqa is one of Magento’s largest partners in Europe and has been working with customers to integrate Cloudinary and ensure that the plugin can cater to a Magento store’s needs.

Read more
As the use of mobiles grows, are websites fading away?
At the end of 2014, activity on smartphones and tablets accounted for 60% of the time Americans spent online, according to comScore. Given the fast migration to mobile, these figures have been growing every year, and this trend in migration is not limited to the US market alone. According to a recent IDC report, the leading mobile vendors shipped a total of 334.4 million smartphones worldwide in the first quarter of 2015 (1Q15), up 16% from 288.3 million units in 1Q14. With this rise in mobile adoption, it seems like more users are turning to their mobile devices to perform online activities rather than their desktop computers.
Read more
Automatic image tagging and categorization

If you have an application that allows users to upload their own photos, it can be very useful to be able to organize these photos according to their content. This will allow you to categorize the content for displaying to all your users and make your image library searchable. Furthermore, you can also learn more about your users according to the content they upload and find different trends of what people care about. Other added benefits can also include the ability to display matching content to your users according to their interests or even match them with other users that share similar interests.

Read more