Cloudinary Blog

How to Sharpen Or Blur Images Through Automation

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.
 

Sharpening Images

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):
 
 
 
Here's the code in Rails:
Copy to clipboard
<%= cl_image_tag("front_face.jpg", :effect => "sharpen") %>
Furthermore, you can fine-tune the `sharpen` effect by specifying a numeric level, e.g., 300:
 
 

 
Here’s the code in PHP:
Copy to clipboard
<?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:
 
 
 
 
Here’s the code in Django:
Copy to clipboard
img = cloudinary.CloudinaryImage("front_face.jpg")
img.image(effect="unsharp_mask")

Blurring Images

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: 
 
 
 
 
To intensify the blurring, pass a numeric level, e.g., 400:
 
 
 
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:
 
 
 
Here’s the code in Rails:
Copy to clipboard
<%= 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:
 
 
 
Here’s the code in Node.js:
Copy to clipboard
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:
 
 
 
Here’s the code in .NET:
Copy to clipboard
string url = cloudinary.Api.UrlImgUp.Transform(
  new CloudinaryDotNet.Transformation().Effect("blur_faces")).BuildUrl("front_face.jpg");


Summarizing It All

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.
 

Recent Blog Posts

Our $2B Valuation

By
Blackstone Growth Invests in Cloudinary

When we started our journey in 2012, we were looking to improve our lives as developers by making it easier for us to handle the arduous tasks of handling images and videos in our code. That initial line of developer code has evolved into a full suite of media experience solutions driven by a mission that gradually revealed itself over the course of the past 10 years: help companies unleash the full potential of their media to create the most engaging visual experiences.

Read more
Direct-to-Consumer E-Commerce Requires Compelling Visual Experiences

When brands like you adopt a direct–to-consumer (DTC) e-commerce approach with no involvement of retailers or marketplaces, you gain direct and timely insight into evolving shopping behaviors. Accordingly, you can accommodate shoppers’ preferences by continually adjusting your product offering and interspersing the shopping journey with moments of excitement and intrigue. Opportunities abound for you to cultivate engaging customer relationships.

Read more
Automatically Translating Videos for an International Audience

No matter your business focus—public service, B2B integration, recruitment—multimedia, in particular video, is remarkably effective in communicating with the audience. Before, making video accessible to diverse viewers involved tasks galore, such as eliciting the service of production studios to manually dub, transcribe, and add subtitles. Those operations were costly and slow, especially for globally destined content.

Read more
Cloudinary Helps Minted Manage Its Image-Generation Pipeline at Scale

Shoppers return time and again to Minted’s global online community of independent artists and designers because they know they can count on unique, statement-making products of the highest quality there. Concurrently, the visual imagery on Minted.com must do justice to the designs into which the creators have poured their hearts and souls. For Minted’s VP of Engineering David Lien, “Because we are a premium brand, we need to ensure that every single one of our product images matches the selected configuration exactly. For example, if you pick an 18x24 art print on blue canvas, we will show that exact combination on the hero images in the PDF.”

Read more
Highlights on ImageCon 2021 and a Preview of ImageCon 2022

New year, same trend! Visual media will continue to play a monumental role in driving online conversions. To keep up with visual-experience trends and best practices, Cloudinary holds an annual conference called ImageCon, a one-of-a-kind event that helps attendees create the most engaging visual experiences possible.

Read more