Overview
Image compression is the process of downsizing an image as much as possible without sacrificing quality so that it can be stored at a lower cost and accessed more quickly.
COS offers a variety of image compression options based on CI for your choice based on your business scenario. Available compression options are as follows: AVIF compression: Converts images to the .avif format, which is a new image format launched by Netflix based on AV1 in February 2020 and currently is supported by browsers such as Chrome and Firefox.
WebP compression: Converts images to the .webp format, which is superior to .jpg in terms of compression. A .webp image is over 25% smaller than a .jpg image with the same quality. This format is suitable for multi-terminal use cases.
HEIF compression: Converts images to the .heif format, which has a super high compression ratio. A .webp image is over 80% smaller than a .jpg image with the same quality. iOS adopts .heif as the default format for photos, and Android P natively supports .heif.
TPG compression: Converts images to the .tpg format, which is a proprietary image format launched by Tencent and supports animated images. Currently, QQ Browser, Qzone, and other Tencent products support .tpg by default. A .tpg image is over 90% or 50% smaller than a .gif or .png image with the same quality, respectively.
Smart image compression: Intelligently determines the subjective quality of an image and automatically adjusts it. It significantly reduces the image size without changing the original format, and delivers a visual effect as closest to the original image as possible.
Note:
Currently, the smart image compression service is available only in Beijing and Shanghai regions.
Use Cases
The image compression feature meets the needs of image compression on various terminals such as PC and app in diverse use cases like ecommerce and media. This effectively reduces the transmission time, loading time, and use of bandwidth and traffic.
Different compression features have different compatibility with existing image formats and browser environments as detailed below:
|
| .jpg, .png, .bmp, .gif, .heif, .webp, and .tpg | A few browsers and systems such as Firefox, Chrome, and Android | | | |
| .jpg, .png, .bmp, .gif, .heif, .tpg, and .avif | More than 95% of browsers and systems such as Edge, Firefox, Chrome, Safari, Android, iOS, and Weixin | | | |
| .jpg, .png, .bmp, .webp, and .avif | Not supported in browsers but natively supported on iOS 11 or later and Android P | | | |
| .jpg, .png, .bmp, .gif, .heif, .webp, and .avif | Only a few browsers such as QQ Browser as special decoders are required | | | |
| .jpg and .png (without changing the format of the original image) | | | | |
Note:
CI provides Windows SDK that integrates TPG and AVIF decoders, so you only need to integrate it into your client to decode and preview TPG and AVIF images. How to Use
AVIF, HEIF, and TPG compression
These three are advanced image formats, and you need to enable the image advanced compression feature first before you can use them. After enabling the advanced compression feature, you can use it by setting the image format conversion parameter to the desired compression format. Specific parameters are as follows: |
| Converts the original image to .avif format for compression. |
| Converts the original image to .heif format for compression. |
| Converts the original image to .tpg format for compression. |
WEBP compression
You can directly use the WEBP compression feature through the format conversion capabilities of basic image processing. Specific parameters are as follows:
|
| Converts the original image to .webp format for compression. |
Smart image compression
The smart image compression feature automatically compresses the images in matching formats, without changing the way you access your images and requiring additional compression parameters.
Compression Examples
Perform all the above compression operations on the original .png image. Assume the link of the original image is:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png
Final request URL:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png?imageMogr2/format/jpeg
Final request URL:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png?imageMogr2/format/webp
Final request URL:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png?imageMogr2/format/heif
Final request URL:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png?imageMogr2/format/tpg
Final request URL:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png?imageMogr2/format/avif
Final request URL:
https://examples-125xxxxx.cos.ap-shanghai.myqcloud.com/test.png
The following table compares the compression ratio of different image compression options (the values are for reference only):
Apakah halaman ini membantu?