Skip to content

How to Sharpen Or Blur Images Through Automation

Images. More likely than not, your web or mobile app is filled to the brim with images, which, from graphical appeal to size and access times, figure prominently in the browsing experience. Image appeal could motivate visitors to return and, in the case of e-commerce, become customers.
 
No matter how outstanding the page design is, many of the images that you as web developers must embed are not in your direct control. Not to mention that social websites contain user-uploaded profile photos; the product photos on e-commerce sites are too numerous to be edited one at a time; and media outlets invariably contain many photographs of different standards.
 
Cloudinary offers an automated tool that tweaks and retouches images by sharpening or blurring them. Obviously, you can also sharpen blurry images with that option.
 
How can you make your website “pop”? It’s easy if you have complete control of the content in your app: a great graphics design can do wonders. But what can you do to spiff up user-uploaded images? 
 
Take this image that was uploaded to Cloudinary, which looks good yet not perfectly sharp:
 
  
 
For more sharpness, set Cloudinary’s effect transformation parameter to `sharpen` (`e_sharpen` for URLs):
 
…/demo/image/upload/e_sharpen/front_face.jpg
 
 
Here’s the code in Rails:
<%= cl_image_tag("front_face.jpg", :effect => "sharpen") %>
Furthermore, you can fine-tune the `sharpen` effect by specifying a numeric level, e.g., 300:
 
…/demo/image/upload/e_sharpen:300/front_face.jpg
 
 
Here’s the code in PHP:
<?php echo cl_image_tag("front_face.jpg", array("effect" => "sharpen:300")) ?>
Sharpening also renders text elements in thumbnails clearer. Take this screenshot that was uploaded to Cloudinary with blurry text snippets in gray:
 
 
 
 
To make the text more readable, add to the URL the parameter `unsharp_mask` which, though similar to `sharpen`, is triggered by a different algorithm:
 
…/demo/image/upload/e_unsharp_mask/text_screenshot.jpg
 

 
 
Here’s the code in Django:
img = cloudinary.CloudinaryImage("front_face.jpg")
img.image(effect="unsharp_mask")

Other scenarios might require that you blur images. Quora, for example, dynamically blurs text snippets if you browse while being logged out. 
 
To blur images with Cloudinary, add the `blur` parameter (`e_blur` for URLs). An example: 
 
…/demo/image/upload/e_blur/front_face.jpg
 
 
 
To intensify the blurring, pass a numeric level, e.g., 400:
 
…/demo/image/upload/e_blur:400/front_face.jpg
 
 
The following example shows an intensely blurred image with reduced opacity along with a text overlay that prompts the audience to sign up on your site to view the full content:
 
…/demo/image/upload/e_blur:500,o_50/g_center,l_text:bold_dark:Sign+up+to+see+more/front_face.jpg
 
 
Here’s the code 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}) %>
To blur only a region of an image, add the `blur_region` parameter and specify the values for the region’s coordinates (x, y, width and height), as in this example:
 
…/demo/image/upload/e_blur_region,x_0,y_0.5,w_1.0/front_face.jpg
 
 
Here’s the code in Node.js:
cloudinary.image("front_face.jpg", { effect: "blur_region", x: 0, y: 0.5, w: 1.0 });
To blur all the faces detected in an image by Cloudinary, add the `blur_faces`parameter to the URL, like this:
 
…/demo/image/upload/e_blur_faces/front_face.jpg
 
 
Here’s the code in .NET:
string url = cloudinary.Api.UrlImgUp.Transform(
  new CloudinaryDotNet.Transformation().Effect("blur_faces")).BuildUrl("front_face.jpg");
Sharpening or blurring images applies an impressive effect to online content. Do take advantage of Cloudinary’s automated tool—replete with calibration options for your development framework—to efficiently and effectively apply those effects in bulk. Subsequently, Cloudinary regenerates all the images in real time and serves them to your audience, optimized through a fast content delivery network (CDN).
 
To try out the features described in this post, start with creating a free account on Cloudinary. Do let us know what you think.
 
Back to top

Featured Post