Community Blog Real-Time Image Processing by Object Storage Service

Real-Time Image Processing by Object Storage Service

In this blog, we will explore the image processing feature of OSS, which helps organizations reduce costs and process images in real time.

By Siddharth Pandey, Solution Architect at Alibaba Cloud

In the world of cloud computing, object storage is one of the most well-known and commonly used features. Taking advantage of cheap and practically limitless storage is not only convenient but also very cost effective. This is where Alibaba Cloud Object Storage Service comes in handy. But we will explore a feature of OSS which goes beyond just object storage, and helps organizations with elastic and real-time processing for images on the fly. To understand this in detail, let's look at the problem statement first.

Problem Statement

WhereBnB is an organization that helps travelers find the perfect accommodation for their next travel. Apart from accommodation, it also helps users get to know the city and its various attraction points so they can plan their trip better. WhereBnB has a mobile app, which is built natively in both Android and iOS. It also has a web application that can be accessed as a website on PC, iPad and various other devices.

Since WhereBnB needs to store lots of images of various hotels, accommodation options and attraction points all around the city on its platform for users, the cost of storing these images makes up a big component of their cloud spending. Also, many times the images need to be resized, cropped and processed in multiple ways in order to make it useful for a certain device from which the user might be accessing WhereBnB's website.

This means that for a single image, WhereBnB needs to have multiple copies, fit for laptop screen, mobile screen, iPad screen and so on with various requirements in different scenarios. This increases their overall spending as they are storing multiple copies of the same image to make it suitable for different use cases.

Current Solution

The cloud architects at WhereBnB thought that since there could be multiple reasons for processing an image, a new processing request should always be completed in real time, so that they don't process the image for a number of use cases that are never experienced in real life. For example, the team resized the image only for large device screens and popular phone screens. If a new user comes on their application using iPad, the image will be resized on the fly for that device. But since there are only few website visitors using iPad, it does not make sense to process the images beforehand since it increases the storage cost. There are many such cases for which this technique can be used.

The architects used the power of serverless computing to achieve this. Every time a new request comes, by the power of functions compute, it will be processed on the fly (incurring compute expense) and then stored for future possible use. This approach saved the company some money by not storing images beforehand for unlikely scenarios.

Current Issues

Even though with serverless computing, unlikely processing scenarios were avoided, there were still a lot of images that were being stored and used regularly. The organization still had to pay for multiple versions of the same image sitting in their buckets. A solution was needed to further optimize this situation and save further cost for the team.

Image Processing

WhereBnB now adopted the Image Processing feature of Alibaba Cloud OSS. With this feature, which is unique in the cloud industry, the team would store only one high definition image and all the other versions required will be processed in real time without having to store these images permanently. There are a lot of processing tasks that can be completed using Image Processing.

Let's explore the features in detail here:

Here is the iconic statue of the sitting Lion at Trafalgar Square in London. WhereBnB lists this as a must visit location for travelers going to London.


This image is uploaded on the team's OSS bucket in Singapore region and has the following address:


But this is a heavy image (2.9 MB with a resolution of 5951 × 3973). We want to reduce the size of this image to 600px for WhereBnB's mobile application. In order to do this, we don't store different version of this image, but rather use Image Processing in OSS and pass this URL to the mobile app:



That's it! By adding '?x-oss-process=image/resize,w_500,limit_0', the image can be processed in real time to a new size!

Let's see what else can we do here. What if the team wants to create an icon out of this image which can be used as a thumbnail on the folder for "Places to visit in London". We do this by adding parameters as follows:



Here, we resized the image as before but also converted the image from a rectangle to a circle which can now be used as a thumbnail! We never need to store any more versions of this image ever again. With Image Processing, we can process the image in real time whenever we want. The WhereBnB team is pretty excited with this because now they don't have to store various versions of the same image. Let's see what else can they do here:

Resize and Blur the Image:



Resize and Crop the image to show only the Lion:



These were some of the useful real-time processing features and there are many more as follows:

  1. Custom Crop
  2. Indexed Cut
  3. Rounded Rectangle
  4. Rotate/AutoRotate
  5. Sharpen/Contrast/Brighten
  6. Quality transformation/Tone
  7. Add Watermark
  8. Format Conversion.

All these features and their respective parameters can be explored on the official documentation at this link.

With the Image Processing feature, organizations can reduce their cost on storage of images by storing one version of the image in the bucket.


With the Image Processing feature of OSS, WhereBnB only needs to pay for the actual consumption of cloud resources, helping them to reduce costs. When you use IMG, the following fees are incurred:

  • Image processing fees: Image processing fees are only charged after you exceed the free quota. The fees are charged based on the size of the source images.
  • Request fees: A GetObject request is generated each time when you use IMG to process an image. You are charged based on the number of generated requests.
  • Traffic fees: You are charged for the outbound traffic over the Internet based on the size of the source images.

Disclaimer: The views expressed herein are for reference only and don't necessarily represent the official views of Alibaba Cloud.

0 0 0
Share on

Alibaba Clouder

2,600 posts | 754 followers

You may also like