When images are involved, web developers have a large set of relevant tools at their disposal. You can display images in your web sites and mobile applications. You can transform and transform such images using image editing and transformation software or cloud-based solutions like Cloudinary. But there are other types of data embedded in image files that can add unique semantic information to the images and are hardly ever used.
Consider what new designs can appear if your graphics designer could assume that only blue themed user uploaded photos will be featured on your homepage. What about featuring only photos that show your users’ faces? How about photos taken with new DSLR model cameras rather than older pocket ones? Only photos taken in the GPS vicinity of your website visitor? We believe that such capabilities can offer a new, important tool for web design and development.
Unfortunately, such semantic data is usually locked safely within the images and rarely utilized by developers and designers. We hope that we can change that by introducing a new Cloudinary API that allows you to easily extract rich information regarding your website and mobile application’s photos. Using this information you can search, sort and classify your images in amazing new ways.
Image search services such as Google Image Search allow you to filter your image search to show only images of a certain color. How is it done? Each image is analyzed and the colors of the images are mapped to one or more leading colors.
Cloudinary now supports finding the leading colors of a given image using a standard palette of 12 main colors. Since Cloudinary is a cloud-based service, all image processing is done online and no software installation is required on your side.
Finding the predominant colors in an image is also useful for stock-photo sites that wants to allow you to narrow photo searching by colors (see our previous post of how-to quickly build a stock-photo site with Cloudinary) and for eCommerce sites. For example: if you have a fashion site, and you want your users to browse only blue or red shirts.
For example, the following image with the public ID ‘fashion1’ was uploaded to Cloudinary:
Using Cloudinary’s Admin API, you can extract the photo’s main colors by setting the ‘colors‘ parameter to true (see reference documentation). Here are examples for Ruby, PHP, Node.js and Python:
As you can see, you get RGB format and percentage breakdown of the 32 colors that best represent the image. ‘#FFFFFF’ is white, representing around half of the image, followed by multiple blue shades (e.g., ‘#011B43’ is 5.8%).
Cloudinary supports face detection based cropping and pixelation. Either a single face or multiple faces can be automatically detected. Our API now supports returning additional information regarding the detected faces in an uploaded photo.
Simply set the ‘faces‘ parameter to true in the same method we showed above for ‘colors‘. Note that you can enable multiple flags in a single call for fetching all information at once. The result includes the exact coordinates of all detected faces, allowing you to easily find out how many faces are available in the photo and their exact positions.
The following Ruby command asks for the faces information of the ‘fashion1’ image:
**Update March 2017: The exif parameter has been deprecated. The exif data can now be extracted using the image_metadata parameter.
Modern digital cameras and smartphones store additional metadata as part of the image files you shoot. Such information includes picture orientation, timestamps, camera model information, photo exposure, GPS location and more.
By setting the ‘exif‘ parameter to true, Cloudinary’s API can extract metadata from image’s (see our reference documentation). In the sections above we’ve shown how to use the Admin API for fetching information of previously uploaded images. You can also request this information while uploading the photos, so it is returned as part of an upload response.
For example, the following PHP command uploaded to Cloudinary a photo that was taken by an iPhone 4 in a portrait orientation.
With the additional knowledge of image metadata and semantic information, you can enhance your image rich web and mobile applications with little effort, while Cloudinary does all the heavy lifting for you. These additional layers of information adds an important aspect that allows Cloudinary to offer a better than ever cloud-based solution to all your online image management and transformation needs.
All these new features were requested by Cloudinary’s users and we thank all of you for that. We have plenty more ideas for enhancing Cloudinary’s capabilities in this area and would love to hear your feedback and suggestions.
The ability to fetch Exif, Faces, Predominant colors and Color histogram is now available to all of Cloudinary’s plans, free and paid. Click here to setup a free Cloudinary account.
Picture yourself developing an e-commerce website where users can upload product images and videos. You’re handling a substantial volume of media files, potentially thousands, as these visual assets play a critical role in attracting buyers and effectively showcasing your products. However, managing an extensive media library can pose complex challenges…