tencent cloud

Cloud Infinite

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Product Overview
Product Strengths
Use Cases
Feature Overview
Regions and Domains
Specifications and Limits
Billing
Billing Overview
Billing Mode
Billable Items
Free Tier
Payment Overdue
Viewing Bill Details
FAQs
Getting Started
Registering and Logging In
Bind Bucket
Uploading and Processing File
Downloading and Deleting Images
Unbinding Buckets
Using CI via COS
Features
Image Processing
Media Processing
Content Moderation
AI Content Recognition
File Processing
Smart Voice
File processing
User Guide
Overview
Bucket Management
Smart Toolbox
Job and Workflow
Data Monitoring
Usage statistics
Use Cases
Copyright Protection Solutions
Image Processing Practices
Working with API Authorization Policies
Workflow Practices
API Documentation
API Overview
Structure
Common Request Headers
Common Response Headers
Activate Vast Service
Image Processing
AI-Based Content Recognition
Smart Audio
Media Processing
Content Moderation
Document Processing
File Processing
Job and Workflow
Cloud Virus Detection
Error Codes
Request Signature
SDK Documentation
SDK Overview
Android SDK
iOS SDK
COS Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Go SDK
COS iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
Mini Program SDK
Personal Information Protection Policy for SDK
Security and Compliance
Permission ‍Management
FAQs
Basic Settings
Document Processing
Media Processing
Content Recognition
Smart Audio
Agreements
Service Level Agreement
Contact Us
Glossary

Basic Image Compression (WebP)

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-11-06 16:19:14

Description

Image compression refers to reducing the image size as much as possible while maintaining the original image quality, thereby saving image storage space, reducing image access traffic, and improving image access speed.
Cloud Infinite (CI) introduced the WebP compression feature, which converts images into the WebP compressed format, outperforming JPG in compression. At the same image quality level, WebP images are over 25% smaller than JPG images, enabling adaptation to multi-terminal usage scenarios.

Authorization Description

When using a sub-account, you need to add the corresponding permission to the action in the authorization policy. For all supported API operations in Cloud Object Storage, see COS action.
Processing during download: Set action to cos:GetObject in the authorization policy.
Processing upon upload: Set action to cos:PutObject in the authorization policy.
Cloud data processing: Set action to cos:PutObject in the authorization policy.
Note:
GetObject resource is the source file, PutObject resource is the transferred file.

Service Activation

The first time you use this feature, Cloud Infinite (CI) will be activated for you by default, and the bucket will automatically bind CI with no need for role authorization, allowing you to use it directly.
Note:
After binding Cloud Infinite, if you manually perform bucket unbind for CI, you will not be able to continue using this function.

Use Limits

When using this API, please confirm the relevant restrictions. For details, see Usage Limits.

Fee Instructions

WebP compression is a paid service with the same fee as basic image processing. For specific fees, see Image Processing Fees. Generated costs will be charged by CI.
If processing during download is used and the download is performed via public network, traffic charges will occur.
Note:
After converting an image to WebP format, some browsers cannot read the exif data of WebP images, resulting in no rotation. See the rotation document and add the auto-orient parameter to rotate the original image before compression.
WebP compression inherits the original image's quality parameters by default. See the quality change document to adjust the compression rate by changing the image quality.

API Examples

Processing upon Download

GET /<ObjectKey>?imageMogr2/format/webp HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>

Processing Upon Upload

PUT /<ObjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Pic-Operations:
{
"is_pic_info": 1,
"rules": [{
"fileid": "exampleobject",
"rule": "imageMogr2/format/webp"
}]
}

Cloud Data Processing

POST /<ObjectKey>?image_process HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Content-length: <Size>
Authorization: <Auth String>
Pic-Operations:
{
"is_pic_info": 1,
"rules": [{
"fileid": "exampleobject",
"rule": "imageMogr2/format/webp"
}]
}
Note:
Authorization: A request header carrying authentication information to verify the validity of the request. The Pic-Operations header should be signed within the signature information. For details, see Request Signature.
Pic-Operations is a string in json format. For specific parameters, see Image Processing mechanism introduction.
When the fileid is the same as the ObjectKey, the output image will overwrite the input image for storage; otherwise, both the input and output images will be stored separately.
The value of fileid needs to be processed through URLEncode.

Processing Parameter Description

Parameter
Description
Type
Required or Not
ObjectKey
File name of the object, for example, folder/sample.jpg.
String
Yes
/format/<Format>
Compression format (here is WebP).
String
Yes

Practical Case

Note:
The practical cases in this document only include the Processing upon Download scenario. This type of processing does not save the output images to the bucket. If you need to save them, please use the Process upon Upload or Cloud Data Processing method.
Assume the input image is in PNG format with a size of 1335.2 KB, as shown in the figure below.

img


Convert the input image to WebP format. The request URL is as follows.
http://example-1258125638.cos.ap-shanghai.myqcloud.com/sample.png?imageMogr2/format/webp
The following figure shows the effect.

img


Compression Ratio Comparison
Format
Image Size
PNG (input image)
1335.2KB
WebP
65 KB (compression ratio: 95.13%)

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック