Cloudinary Blog

Automatic image sharpening and blurring in the cloud

by Nadav Soferman
Images. Your web (or mobile) application is probably filled to the brim with images. You might be surprised at just how much impact these images have on your visitors. From their graphical appeal to their size and access times - these images determine your visitors browsing experience and ultimately their conversion to repeating visitors and paying clients.
Now, while your graphic designer has created a cool graphical concept, many of the images you need to embed inside it are not in your direct control. Social websites contain profile photos uploaded by their users. E-commerce solutions contain many product photos that can't be edited one at a time. Media outlets contain many photographs of different consistency.
Having a tool in your belt that offers automatic tweaks and retouches for all these images is quite handy. Here a couple of things you can do with Cloudinary that can really improve your website.

Image sharpening

How can you make your website "pop"? it's easy if you control the exact content across your web application - a great graphics design can make wonders. But what can we do to improve user uploaded images? 
Let's look look at the following image uploaded to Cloudinary:
The photo looks good. But just take a look at what a bit of sharpness can do to it. 
You can add sharpness by setting the effect transformation parameter to sharpen (or e_sharpen for URLs):
Here's the same example in Rails:
<%= cl_image_tag("front_face.jpg", :effect => "sharpen") %>
You can control the strength of the sharpen effect to match your taste. Here's a more intense sharpening of the same image by setting the sharpen level to 300. Quite a nice photographic effect.

Same example in PHP:
<?php echo cl_image_tag("front_face.jpg", array("effect" => "sharpen:300")) ?>
Sharpening is also useful in making text elements in thumbnails clearer. For example, the following screenshot was uploaded to Cloudinary. As you can see the small gray text snippets are not so clear here.
Sharpening such an screenshot would make the text more readable. The following example sharpened this image. This time using the unsharp_mask effect that is similar to sharpen but uses a different algorithm. Much more readable:
Same example in Django:
img = cloudinary.CloudinaryImage("front_face.jpg")

Image blurring

Image sharpening is useful for improving images and making them "pop". But sometimes you would want to aim for the opposite effect. Quora, for example, is using dynamically created blurred snippets of text if you're browsing an answer while being logged out. How can you do that using Cloudinary?
To blur images, you can use Cloudinary's blur effect (e_blur for URLs). Here's an example: 
You can also make the blurring more intense by passing a numeric level. The following example applies the blur effect with a 400 intensity on the sample image:
In the following example, we blurred the image intensely and also reduced its opacity. Then we added a text overlay that calls users to sign up to your site if they want to view the full content:
Sample example in Rails:
<%= cl_image_tag("front_face.jpg", 
                 :overlay => "text:bold_dark:Sign up to see more",
                 :gravity => :center,  
                 :transformation => {:effect => "blur:500", :opacity => 50}) %>
Sometimes you want to blur only a certain region of an image. You can use the blur_region effect together with exact coordinates specified by x, y, width and height parameters. Here's an example that blurs only part of an uploaded screenshot:
Same example in Node.js:
cloudinary.image("front_face.jpg", { effect: "blur_region", x: 0, y: 0.5, w: 1.0 });
You can also automatically blur all faces detected in an image using Cloudinary's blur_faces. In the following example the face was automatically detected and blurred using the default level:
Same example in .NET:
string url = cloudinary.Api.UrlImgUp.Transform(
  new CloudinaryDotNet.Transformation().Effect("blur_faces")).BuildUrl("front_face.jpg");


Automatic image sharpening and blurring can do wonders to a website. For static assets, you can do that manually using your favorite image manipulation software. With Cloudinary such effects can be automatically applied to millions of user-uploaded images with ease. And if you decide to spruce up the graphical effects in your site's images, you can simply modify the transformation parameters in your development framework of choice. All images will be regenerated on the fly using the updated effect and will be served to your users optimized through a fast CDN.
It would be great if you try out the new filters and tell us when you think. If you don't have a Cloudinary account yet, you can create one for free.

Recent Blog Posts

Optimizing web performance and your bottom line

by Robert Moseley
Optimize your website and app for maximum user engagement
Patience is not a virtue for website visitors and online shoppers. Every fraction of a second counts when it comes to keeping – or losing – a visitor to your website.  
Loading time is a major contributing factor to page abandonment, according to an infographic on the Kissmetrics blog using statistics from Akamai and Gomez. Because the average web visitor has no patience for a page that takes too long to load, abandonment increases as a percentage with every second of load time. Nearly 40 percent of users will abandon a page after 10 seconds, the blog noted. Mobile Internet users probably experience the most frustration with this issue –  73 percent noted that they’ve encountered a website that was too slow to load. 
Read more
Is your website offering the best user experience?
The most common frustrations voiced by people when visiting a website are the time it takes for pages to load and the amount of bandwidth some sites eat from their monthly mobile plans. 
What these users might not realize is that, in many cases, the culprit is the same: website image performance. Ensuring images are optimized is particularly important to businesses who manage these sites since they account for the majority of the downloaded bytes on a web page, and can slow down load times considerably. 
Read more
Improve your site with content personalization & A/B testing

Personalization of web content is becoming increasingly important for businesses to gain – and maintain – their competitive advantage. Web personalization is key to increasing conversion rates and return rates, as well as boosting retention, time-on-site, and page views, according to a December 2015 VentureBeat study, which noted that 87 percent of companies have seen a lift of at least 5 percent in their most important metrics as a result of personalization. 
Read more
Dynamic ZIP files generation with a single line of code

As a developer, you want to allow your users to download multiple files in a single click. An easy way to download multiple files and share them is to generate a ZIP file. When images are involved, you may also want to normalize the original images before including them in the ZIP file, by scaling them down to the same maximum resolution or converting them to the same format.

Read more