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.
 

page load speed

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

Partner news: Cloudinary-Getty Images Integration

Supported by intelligent automation, Cloudinary serves as an effective conduit between media asset management and delivery so you can take maximum advantage of assets, compress workflows, and build and coordinate engaging and inspiring customer experiences. Through Cloudinary’s Digital Asset Management (DAM) solution, which employs the company’s innovative image and video APIs, creative and marketing teams can benefit from them, as well as from many AI-powered and automated capabilities. As a result, you can transform, optimize, and deliver media at scale on an intuitive UI.

Read more
Why Audio in Video Matters

Many content creators and consumers tend to regard video as visuals, but that’s only part of the experience. Immersive video content includes strong audio. Just like in a movie, the audio for video content comprises many components: the narrator or subjects, the background music that sets the mood and draws viewers in, sound effects, and so forth.

Read more

For Developers: the HTML <picture> Element Explained

By Amarachi Amaechi
For Developers: the HTML <picture> Element Explained

We all know the good ol', tireless <img> element, which has been a long-time go-to for inserting graphics into webpages. Time doesn’t stop, however, and neither do technological advancements. So, let’s get you up to speed with the element’s modern alternative: the <picture> element.

Read more