Serverless image processing with Cloud Object Storage


When a new image is uploaded to your cloud storage, wouldn’t it be great to also run some additional processing functions on that image? For example, convert it to a thumbnail size, automatically enhance the colors, or analyze it to figure out what’s in the image. Serverless is a natural choice for this type of processing and analysis because your functions will be run on demand, at scale, and in the cloud in reaction to cloud object storage events.


In this application, you upload an image to a web application that is stored in IBM Cloud Object Storage, which triggers your serverless functions to run. Those functions perform some image processing and analysis, such as charcoaling the image and running visual recognition on it. After the analysis and processing is done, the results are stored in a different Cloud Object Storage bucket, which can then be read.

When you have completed this code pattern, you will understand how to:

  • Set up a Cloud Object Storage instance on IBM Cloud.
  • Create and deploy IBM Cloud Functions from a manifest.yaml file.
  • Access the Cloud Object Storage instance from Cloud Functions.
  • Set up a trigger to fire when new items are created in Cloud Object Storage.
  • Deploy a Node.js with Express web application to IBM Cloud.


serverless cloud object storage image processing architecture flow diagram

  1. The user uploads an image through the web application UI.
  2. The web application writes the image to the Cloud Object Storage instance.
  3. A trigger listening to the Cloud Object Storage bucket is fired.
  4. The trigger fires two actions to be run:

    • A gray scale function processes the image, changing it to gray scale.
    • A visual recognition function uses the Visual Recognition service to analyze the content of the image, and then parses the results from the Visual Recognition service.
  5. Each action writes back to Cloud Object Storage:

    • The gray scale function writes the processed image to a Cloud Object Storage bucket for processing.
    • The visual recognition function writes a .txt document to the Cloud Object Storage bucket for processing.


Ready to give it a try? See the README file for detailed instructions.

  1. Create required services on IBM Cloud.
  2. Log in and set up your IBM Cloud CLI with the Cloud Functions plugin.
  3. Create the Cloud Object Storage experimental package binding.
  4. Create required environment variables and deploy Cloud Functions.
  5. Bind service credentials to the created Cloud Object Storage package.
  6. Deploy the web application.