tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Basic Image Compression (WebP)

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-01-09 11:19:55

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%)

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan