DEV Community

Man yin Mandy Wong
Man yin Mandy Wong

Posted on

Tencent Cloud COS + CI for a Comprehensive Image Solution

In daily development, you inevitably need to store images such as user profile photos and chat images. A common practice is to directly store such images on the server. However, it is a better idea to store website images and other static resources in a cloud storage service, retain backup files locally, respond to read requests in the cloud, and add a layer of CDN. By doing so, you can separate storage from computing, which makes it easier for you to manage your website and make your website faster to load. To implement separate storage, the storage service must be stable and reliable, and Tencent Cloud COS is your ideal choice.

• What is COS?

Cloud Object Storage (COS) is a distributed storage service with no directory hierarchy or data format restrictions. It allows you to store massive amounts of data and view data objects in the cloud at any time over HTTP or HTTPS. In this way, it delivers a data storage solution featuring high scalability, reliability, and security at low costs to both enterprise and individual users. It offers four object storage classes based on the access frequency. This article takes STANDARD, the default storage class, as an example to describe the high data durability, availability, and performance implemented by COS.

You may want to perform processing operations on the images stored in the cloud, for example, adding watermarks, cropping images, and moderating content to detect pornographic, politically sensitive, or terrorism information. Traditionally, you have to call APIs of other separate services to this end, but now you can directly leverage the CI service integrated into COS to process images with speed and ease. CI comes with a rich set of features, such as image processing, moderation, and recognition, enabling you to treat media data in COS by simply calling corresponding CI APIs. This pushes the boundaries of COS and makes it more than just a storage system.

• What is CI?

Cloud Infinite (CI) is a professional integrated image solution provided by Tencent Cloud. It has a wide variety of features, including image upload, download, storage, processing, and recognition, and opens up Qzone's decade of technical expertise in image services.

CI offers customized image recognition services as well as flexible image processing services such as cropping, compression, watermarking, and transcoding. Its secure, stable, and efficient cloud data processing capabilities fully meet your diverse needs for media processing in various business scenarios.

• Use cases

To call CI in COS for basic image processing such as cropping, compression, and watermarking, you don't even need to write any code; instead, you can simply splice URL parameters as follows:

1. Basic image processing

To call basic image processing features, you don't need to use SDKs; instead, you can simply splice URL parameters as instructed at https://cloud.tencent.com/document/product/460/6924.

2. Rotation

CI uses the "imageMogr2" API to rotate an image by a specified angle or automatically. You can visit the sample address in the document to rotate an image by 90 degrees clockwise.

3. Gaussian blurring

CI uses the "imageMogr2" API to blur an image.

4. Image/Text watermarking

Watermarking is a frequently used feature. CI provides corresponding parameters for you to call it easily. It uses the "watermark" API to implement real-time image and text watermarking.

5. Pipeline operator

The "|" pipeline operator of CI enables you to perform multiple processing tasks on an image in the sequence, such as scaling and watermarking.

You can append a style separator "?" to the end of an image URL and then add processing operations separated by the pipeline operator "|". Then, these operations will be performed in sequence. Currently, up to three operations can be added. The sample here uses pipeline operators. As the input image is large and the logo is small, image scaling is performed first before the logo is added as a watermark.

If you don't bother to splice the URL parameters by entering many strings, we've also got you covered by offering the image style feature. In the bucket list, select the target bucket. Then, on the "Image Processing" tab, add an image style. COS and CI together make a comprehensive image solution that satisfies different image processing needs of applications and websites. It not only provides convenient image services quickly, but also adjusts resources dynamically based on the elastic scheduling of Tencent Cloud capabilities to sustain sudden business changes.

Come try out these powerful features and discover more.

Read more at: https://www.tencentcloud.com/dynamic/blogs/sample-article/100385

Top comments (0)