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

Using Smart Compression through API

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2026-01-19 11:35:26

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

Ajuda e Suporte

Esta página foi útil?

comentários