Compressing Images
When an image is uploaded or updated to bucket your-bucket-input, an event is generated to trigger the function. The function compresses the image and stores the compressed one into bucket your-bucket-output.
Uploading an Image to Generate an Event
Log in to the OBS console, go to the object page of the your-bucket-input bucket, and upload the image.jpg image, as shown in Figure 1.
The size of the original image.jpg file exceeds 28 KB.
Triggering the Function
After the image is uploaded to bucket your-bucket-input, OBS generates an event to trigger the image compressing function. The function compresses the image and stores the compressed one into bucket your-bucket-output. You can view running logs of the function on the Logs tab page, as shown in Figure 2.
On the your-bucket-output page on the OBS console, you can see the compressed image image-thumbnail.jpg, whose size is less than 8 KB after compression, as shown in Figure 3.
Last Article: Adding an Event Source
Next Article: Watermarking Images



Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.