Serverless image processing with Cloud Object Storage
Trigger functions that convert, enhance, and analyze images that are uploaded to the cloud
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.
- The user uploads an image through the web application UI.
- The web application writes the image to the Cloud Object Storage instance.
- A trigger listening to the Cloud Object Storage bucket is fired.
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.
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.
- Create required services on IBM Cloud.
- Log in and set up your IBM Cloud CLI with the Cloud Functions plugin.
- Create the Cloud Object Storage experimental package binding.
- Create required environment variables and deploy Cloud Functions.
- Bind service credentials to the created Cloud Object Storage package.
- Deploy the web application.