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

Creating an API With Python Flask to Upload Files to Cloudinary

Code

Cloudinary offers SDKs for many programming languages and frameworks. Even though it also offers an Upload API endpoint for both back-end and front-end code, most developers find the SDKs very helpful. If you're working with a powerful back-end framework like Python Flask, you'll be happy to hear that a Python SDK is now available.
This tutorial walks you through the process of building an API to upload images to Cloudinary. You can also upload other file types, including video and even nonmedia files, with the API.

Read more
How to Use the Cloudinary Media Editor Widget

At Cloudinary, we manage the entire pipeline of media assets for thousands of customers of varying sizes from numerous verticals.

As part of our commitment to support the entire flow of media assets, we are now introducing an intuitive media editing widget: an out­-of­-the-­box, interactive UI providing your users with a set of common image editing actions for immediate use on your website or web app. The widget is interactive and simple, built on Cloudinary's transformation capabilities, and requiring only a few lines of code to integrate. Afterwards, you can seamlessly and effortlessly add content to your site or app with no need for in-house image editing capabilities.

Read more
Shoppable Video Is Becoming Popular in E-Commerce

As pandemic restrictions necessitated, many shopping trips in 2020 took place outside the traditional brick-and-mortar store, or at least void of the physical aisle-browsing experience. Same-day curbside pickup became a safe and convenient alternative, and e-commerce transactions skyrocketed as consumers shopped online. In fact, Digital Commerce 360 estimates that, compared to 2019, e-commerce transactions grew by more than 40% last year.

Read more
Enhance Your Travel Site With Cloudinary in Anticipation of a Return to New Normal

Read more
The Benefits of Headless DAMs

Headless is not a buzzword anymore. In fact, the concept of headless architecture is gaining momentum due to the flexibility it offers for composing new experiences and for tackling the undue complexity of an ever-evolving technology stack. That’s because while the evolution of the martech landscape has enabled disruptive, digital innovations, the approach of buying point solutions for solving specific challenges can expose companies to the complicated nature of new technologies, systems, and platforms.

Read more