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

Using Smart Compression through API

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-01-19 11:34:40

Feature Description

Smart Image Compression intelligently determines the subjective quality of images and performs automatic adjustment. Without changing the original format of the image, it significantly reduces the file size compared to the original while maintaining the visual quality as close to the original as possible. This helps you reduce image access traffic and improve image loading speed. The feature supports the following processing methods:
Processing during download
Processing during upload
Processing in the cloud

Authorization Description

When used with a sub-account, the ci:SetImageSlim permission is required. For details, see Cloud Infinite action.
Process during download: Set action to cos:GetObject in the authorization policy.
Process upon upload: Set action to cos:PutObject in the authorization policy.
Process data in the cloud: Set action to cos:PutObject in the authorization policy.
Note:
The resource for GetObject corresponds to the source file, and the resource for PutObject corresponds to the transferred file.

Service Activation

Using this feature requires enabling Cloud Infinite in advance and binding a bucket. For details, see Binding a Bucket.
Use this feature requires enabling the Smart Compression API functionality in advance via the console or API. For details, see Smart Image Compression.

Use Limits

When using this API, please confirm the relevant restrictions first. For details, see Specifications and Limits.
Does not support processing images in COS Archive Storage or Deep Archive Storage. If you need to process such files, please restore archived files.

Fee Description

Smart Image Compression is a paid service. The incurred fees will be collected by Cloud Infinite. For detailed billing information, see Image Processing Fees.
If "process during download" is adopted and the download is performed via the public network, the call will incur traffic charges.
If the image is stored in the COS Infrequent Access storage, the API call will generate COS data retrieval fees.

Interface Format

Processing during download

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

Processing during 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.jpg",
"rule": "imageSlim"
}]
}

Processing in the cloud

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.jpg",
"rule": "imageSlim"
}]
}
Note:
Authorization: Carries authentication information for verifying the legitimacy of requests. The Pic-Operations header must include the signature information. For details, see the Request Signature document.
Pic-Operations is a JSON format string. Specific parameter information can be found in Image Processing Mechanism Introduction.
When fileid is the same as ObjectKey, the processed image will overwrite the original stored image; when they are different, the original image and the processed image will be stored separately.
The value of fileid needs to be URL-encoded.

Processing Parameter Description

Parameter
Definition
Required
ObjectKey
Object file name, for example: folder/sample.jpg.
Yes
imageSlim
Fixed parameters, means smart compression.
Yes
Note:
When using processing during download, you can determine whether the image has been compressed by checking the X-Slimflag response header. This response header contains the following three values:
0: Indicates compression failed;
1: Indicates compression succeeded;
2: Indicates no compression was performed, and the original image was returned.

Real Case

Note:
The actual cases in this document contain only processing during download. This type of processing will not save the processed images to the bucket. If you need saving, you can refer to the Image Processing Mechanism Introduction document and configure processing during upload or processing in the cloud.
Assume the original image format is png, the image size is 1335.2 KB, as shown below:

img


Perform Smart Image Compression on the image, the request URL is as follows:
http://example-1258125638.cos.ap-shanghai.myqcloud.com/sample.png?imageSlim
Output:

img


Compression Rate Comparison
Format
Image Size
png (original image)
1335.2KB
png (Smart Compressed image)
549KB (compression rate 58.88%)

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백