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

Generic Image Matting

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2026-01-09 22:32:21

Feature Overview

Cloud Infinite provides general matting through the AIPicMatting API. It can detect entity information in a picture, automatically split the background, generate picture that only contain entity information, and can support persistent processing, processing in the cloud, and processing during download.

Use Limits

When using this API, please first confirm the relevant restrictions. For details, see Specifications and Limits.

Authorization Guide

When used with a sub-account, corresponding permissions must be granted. For COS permissions, please refer to Cloud Object Storage. For other CI permissions, please refer to Cloud Infinite.
Processing during download: Set action to cos:GetObject, ci:CreateS3AIPicMattingJob in the authorization policy.
Processing during upload: Set action cos:PutObject in the authorization policy
Processing in the cloud: Set the action to cos:GetObject and cos:PutObject in the authorization policy. (Note: GetObject corresponds to the source file, and 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 CI.

Fee Description

This API is a paid service. The incurred fees will be collected by Cloud Infinite. For detailed billing information, see Content Recognition Expenses.

Processing Method 1: Processing during Download

Request

 Original images are stored in COS.
GET /<ObjectKey>?ci-process=AIPicMatting HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
 Original images come from other links.
GET /?ci-process=AIPicMatting&detect-url=<detect-url> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>

Processing Parameter

Operation name: AIPicMatting
Parameter
Meaning
Type
Required
ObjectKey
Object filename, for example: folder/document.jpg
String
Yes
ci-process
Cloud Infinite processing capability, general matting is fixed as AIPicMatting
String
Yes
detect-url
You can fill in the detect-url to process any publicly accessible image link. If detect-url is not specified, the backend will process the ObjectKey by default. If detect-url is filled in, the backend will process the detect-url link, and there is no need to fill in the ObjectKey. Example of detect-url: http://www.example.com/abc.jpg, which needs to be UrlEncoded and processed into http%25253A%25252F%25252Fwww.example.com%25252Fabc.jpg.
String
No
center-layout
Center the subject for matting; display centered when the value is 1, take no action when the value is 0, default is 0
Integer
No
padding-layout
Add padding to all four sides of the processed image, in the form of padding-layout = <dx>x<dy>. The left and right sides are padded by dx pixels each, while the top and bottom sides are padded by dy pixels each. For example: padding-layout = 20x10
Default does not perform blanking operation, maximum value of dx and dy is 1000 pixels.
String
No

Response

HTTP/1.1 200 OK
Content-Type: image/png
Content-Length: 98645
Date: Tue, 23 Apr 2022 09:06:16 GMT
Server: tencent-ci
Status: 200 OK
x-cos-request-id: NWFjMzQ0MDZfOTBmYTUwXzZkZV8z****

[pic-content]
The processed image is returned directly in the response body.

Processing Method 2: Process during Upload

Request Syntax

PUT /<ObjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Pic-Operations: <PicOperations>
Note:
Authorization: Auth String. For details, see Request Signature documentation.

Request

Request Header

This API uses common request headers. For details, see Common Request Headers documentation.
In addition to the common request headers, the following headers are required:
Header Name
Description
Type
Pic-Operations
Parameters for image operations
String
Pic-Operations is a JSON format string. The specific parameters are as follows:
Parameter
Type
Required
Description
is_pic_info
Int
No
Whether to return original image information, 0 for no return, 1 for return, default is 0
rules
Array
No
Processing rules, content recognition only supports one rule
Each item in the rules (JSON array) has the following specific parameters:
Parameter
Type
Required
Description
bucket
String
No
Destination bucket name for storing results, format is BucketName-AppId. If not specified, it defaults to the current bucket.
fileid
String
Yes
Storage path and name of the processed file. Name rule description:
For example, the source file path and name are: /p1/test1.jpg
Absolute paths start with /, for example, when the fileid value is /p2/test2.jpg, it means a file named test2.jpg is stored in the p2 folder.
Relative paths do not start with /, for example, when the fileid value is p2/test2.jpg, it means a new p2 folder is created in the p1 folder, and then a file named test2.jpg is stored in the p2 folder.
Do not end with /, otherwise an empty filename will occur.
If you want the repaired image to overwrite the original image, set the fileid field to <ObjectKey>
rule
String
Yes
Fixed as: ci-process = AIPicMatting, other processing parameters refer to during download

Request Body

The request body contains the original image to be processed.
[Image Content]

Response

Response Header

This API only returns common response headers. For details, see Common Response Headers documentation.

Response Body

The response body is returned as application/xml, and the data content is as follows:
Node Name (Keyword)
Parent Node
Description
Type
UploadResult
None
Request result
Container
The content of UploadResult:
Node Name (Keyword)
Parent Node
Description
Type
OriginalInfo
UploadResult
Image information
Container
ProcessResults
UploadResult
Request processing result
Container
The content of the OriginalInfo node:
Node Name
Parent Node
Description
Type
Key
OriginalInfo
Original image file name
String
Location
OriginalInfo
image path
String
ETag
OriginalInfo
Original image ETag value
String
The content of the ProcessResults node:
Node Name (Keyword)
Parent Node
Description
Type
Object
ProcessResults
Processing result of each image
Container
The content of the Object node:
Node Name (Keyword)
Parent Node
Description
Type
Key
Object
Image file name after matting
String
Location
Object
Image link after matting
String
ETag
Object
ETag value of the image after matting
String
Size
Object
Image size after matting
Int

Practical Example

Request

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": "ci-process=AIPicMatting"
}]
}
Processed images are stored to bucket, with the value of the fileid as the object name.

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 645
Date: Tue, 23 Apr 2022 09:06:16 GMT
Status: 200 OK
Server: tencent-ci
x-cos-request-id: NWFjMzQ0MDZfOTBmYTUwXzZkZV8z****

<UploadResult>
<OriginalInfo>
<Key>goods_matting.jpg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/filename.jpg</Location>
<ETag>"ed60e3598e6862d8c8443a06acfb2153"</ETag>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>goods_matting_process.jpeg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/exampleobject</Location>
<Format/>
<Size>354256</Size>
<ETag>"521451f63c331becf533e466732c1091"</ETag>
</Object>
</ProcessResults>
</UploadResult>

Processing Method 3: Processing in the Cloud

Request Syntax

POST /<ObjectKey>?image_process HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Pic-Operations: <PicOperations>
Note:
Authorization: Auth String. For details, see Request Signature documentation.

Request

Request Header

This API uses common request headers. For details, see Common Request Headers documentation.
In addition to common headers, the following headers are required:
Header Name
Description
Type
Pic-Operations
Parameters for image operations
String
Pic-Operations is a JSON format string. The specific parameters are as follows:
Parameter Name
Type
Required
Description
is_pic_info
Int
No
Whether to return original image information, 0 for no return, 1 for return, default is 0
rules
Array
No
Processing rules, one rule corresponds to one processing result (currently supports five rules), leave blank to skip image processing.
Each item in the rules (JSON array) has the following specific parameters:
Parameter
Type
Required
Description
bucket
String
No
Destination bucket name for storing results, format is BucketName-AppId. If not specified, it defaults to the current bucket.
fileid
String
Yes
Storage path and name of the processed file. Name rule description:
For example, the source file path and name are: /p1/test1.jpg
Absolute paths start with /, for example, when the fileid value is /p2/test2.jpg, it means a file named test2.jpg is stored in the p2 folder.
Relative paths do not start with /, for example, when the fileid value is p2/test2.jpg, it means a new p2 folder is created in the p1 folder, and then a file named test2.jpg is stored in the p2 folder.
Do not end with /, otherwise an empty filename will occur.
If you want the repaired image to overwrite the original image, set the fileid field to <ObjectKey>
rule
String
Yes
Fixed as: ci-process = AIPicMatting
center-layout, padding-layout, and processing during download

Request Body

The request body contains the original image to be processed.
[Image Content]

Response

Response Header

This API only returns common response headers. For details, see Common Response Headers documentation.

Response Body

The response body is returned as application/xml, and the data content is as follows:
Node Name (Keyword)
Parent Node
Description
Type
UploadResult
None
Request result.
Container
The content of UploadResult:
Node Name (Keyword)
Parent Node
Description
Type
OriginalInfo
UploadResult
Image information
Container
ProcessResults
UploadResult
Request processing result
Container
The content of the OriginalInfo node:
Node Name
Parent Node
Description
Type
Key
OriginalInfo
Original image file name
String
Location
OriginalInfo
Original image path
String
ETag
OriginalInfo
Original image ETag value
String
The content of ProcessResults node:
Node Name (Keyword)
Parent Node
Description
Type
Object
ProcessResults
Processing result of each image
Container
The content of Object node:
Node Name (Keyword)
Parent Node
Description
Type
Key
Object
Image file name after matting
String
Location
Object
Image link after matting
String
ETag
Object
ETag value of the image after matting
String
Size
Object
Image size after matting
Int

Practical Example

Request

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:
{
"rules": [{
"fileid": "exampleobject",
"rule": "ci-process=AIPicMatting"
}]
}
Processed images are stored to bucket, with the value of the fileid as the object name.

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 645
Date: Tue, 23 Apr 2022 09:06:16 GMT
Status: 200 OK
Server: tencent-ci
x-cos-request-id: NWFjMzQ0MDZfOTBmYTUwXzZkZV8z****

<UploadResult>
<OriginalInfo>
<Key>goods_matting.jpg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/filename.jpg</Location>
<ETag>"ed60e3598e6862d8c8443a06acfb2153"</ETag>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>goods_matting_process.jpeg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/exampleobject</Location>
<Format/>
<Size>354256</Size>
<ETag>"521451f63c331becf533e466732c1091"</ETag>
</Object>
</ProcessResults>
</UploadResult>


Ajuda e Suporte

Esta página foi útil?

comentários