tencent cloud

Image Repair
Last updated: 2025-09-09 20:02:20
Image Repair
Last updated: 2025-09-09 20:02:20

Feature Overview

Tencent Cloud Data CI can detect and remove common logos in images through the ImageRepair interface, and perform intelligent fixes on the removed parts.
Note:
This interface belongs to a GET request. It uses a synchronous request method and requires carrying a signature. For specific signature settings, please see Request Signature.

Authorization Description

When using with a sub-account, corresponding permissions must be granted. For COS permissions, please refer to COS action. For CI permissions, please refer to Cloud Infinite action.
Processing during download: Set action to authorization policy with cos:GetObject, ci:CreateImageRepairJob.
Process upon upload: Set action to authorization policy with cos:PutObject.
Cloud Data Processing: In the authorization policy, set the action to cos:GetObject and cos:PutObject (Note: The resource corresponding to GetObject is the source file, and the resource corresponding to PutObject is the transferred file).

Service Activation

Using this feature requires enabling Cloud Infinite in advance and binding a bucket.

Use Limits

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

Fee Description

This API is a paid service. The incurred fees will be collected by Cloud Infinite. For detailed billing instructions, please refer to Content Recognition.


Processing Method 1: Processing during Download

Request

Request Syntax

Original images are stored on COS.
GET /<ObjectKey>?ci-process=ImageRepair HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>

Request parameters

Parameter
Meaning
Type
Required or Not
ObjectKey
object filename, for example: folder/document.jpg
String
Yes
ci-process
CI processing capability, image logo removal fixed as ImageRepair
String
Yes
MaskPic
mask (region location in the image that needs to be removed), image address, private images must carry a signature, required to pass through URL-safe Base64 encoding. For example, if the mask image is http://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/shuiyin_2.png, the encoded string at this location is aHR0cDovL2V4YW1wbGVidWNrZXQtMTI1MDAwMDAwMC5jb3MuYXAtZ3Vhbmd6aG91Lm15cWNsb3VkLmNvbS9zaHVpeWluXzIucG5n
String
No
MaskPoly
For example: [[[608, 794], [1024, 794], [1024, 842], [608, 842]],[[1295, 62], [1295, 30], [1597, 32],[1597,64]]]. Enter the coordinates of each point of the polygon in clockwise order. Each polygon: [[x1, y1], [x2, y2]...], in the form of a 3D matrix (multiple polygons: [polygon1, polygon2]) or a 2D matrix (single polygon), and required to pass through URL-safe Base64 encoding. When MaskPoly is filled in simultaneously with MaskPic, the value of MaskPic takes precedence.
String
No

Response

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

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

Processing Method 2: Process Upon Upload

Request

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: A request header that carries authentication information for verifying the legitimacy of requests. The Pic-Operations header must be included in the signed information. For details, see the Request Signature document.

Request header

This API only uses common request headers. For details, see the Common Request Headers document.
In addition to common headers, the following headers need to be provided:
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 or Not
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). If left blank, no image processing will be performed.
Each item in the rules (json array) has the following specific parameters:
Parameter Name
Type
Required or Not
Description
bucket
String
No
Destination bucket name for storing results, in the format 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 file path and filename of the source file are: /p1/test1.jpg
An absolute path starts with /. For example, when the fileid value is /p2/test2.jpg, it means a file named test2.jpg is stored in the p2 folder.
A path not starting with / is a relative path. For example, when the fileid value is p2/test2.jpg, it means a new p2 folder is created in the p1 folder, and a file named test2.jpg is stored in the p2 folder.
Do not end with /, as this will result in an empty filename.
If you want the repaired image to overwrite the original image, set the fileid field to <ObjectKey>.
rule
String
Yes
Processing parameters, ci-process = ImageRepair&MaskPic = <MaskPic> & MaskPoly = <MaskPoly>, specific parameter descriptions are in the table below
The following are the relevant parameters for image restoration:
Parameter Name
Description
Type
Required or Not
ci-process
CI processing capability, image logo removal fixed as ImageRepair
String
Yes
MaskPic
mask (region location to be removed in the image) image address, private images must carry a signature, and must be processed through URL-safe Base64 encoding. For example, if the mask image is http://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/shuiyin_2.png, the encoded string here is aHR0cDovL2V4YW1wbGVidWNrZXQtMTI1MDAwMDAwMC5jb3MuYXAtZ3Vhbmd6aG91Lm15cWNsb3VkLmNvbS9zaHVpeWluXzIucG5n
String
No
MaskPoly
For example: [[[608, 794], [1024, 794], [1024, 842], [608, 842]],[[1295, 62], [1295, 30], [1597, 32],[1597,64]]]. Enter the coordinates of each point of the polygon in clockwise order. Each polygon: [[x1, y1], [x2, y2]...], in the form of a 3D matrix (multiple polygons: [polygon1, polygon2]) or a 2D matrix (single polygon), and required to pass through URL-safe Base64 encoding. When MaskPoly is filled in simultaneously with MaskPic, the value of MaskPic takes precedence.
String
No

Request body.

The request body content is the original image to be fixed
[Image Content]

Response

Response Headers

This API returns common response headers. For details, see the Common Response Headers document.

Response Body

The response body returns with a content-type of application/xml. The specific 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 filename
String
Location
OriginalInfo
Image path
String
Process results within the ProcessResults node
Node Name (Keyword)
Parent Node
Description
Type
Object
ProcessResults
The processing result of each image
Container
The content of the Object node
Node Name (Keyword)
Parent Node
Description
Type
Key
Object
Repaired image file name
String
Location
Object
Repaired image link
String
ETag
Object
Repaired image ETag value
String
Size
Object
Image size
Int

Examples

Request

PUT /filename.jpg HTTP/1.1
Host: examplebucket-1250000000.cos.ap-chengdu.myqcloud.com
Date: Wed, 28 Oct 2015 20:32:00 GMT
Authorization: Auth String
Pic-Operations: {"rules":[{"fileid":"test.jpg","rule":"ci-process=ImageRepair&MaskPic=aHR0cDovL3BldGVyLWd6LTEyNTE3MDQ3MDguY29zLmFwLWd1YW5nemhvdS5teXFjbG91ZC5jb20vcGljX21hc2suanBn"}]}
Content-Length: 64

[Image Content]

Response

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

<UploadResult>
<OriginalInfo>
<Key>456.jpeg</Key>
<Location>examplebucket-1250000000.cos.ap-chongqing.myqcloud.com/456.jpeg</Location>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>test.jpg</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/test.jpg</Location>
<ETag>"eaa4e3d8fd498bbc63be3b71c46b9c61f23e3f0c"</ETag>
</Object>
</ProcessResults>
</UploadResult>

Processing Method 3: Cloud Data Processing

Request

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 the Request Signature document.

Request Content

Parameter Name
Description
Type
ObjectKey
Image name to be fixed, must be a filename stored in COS, for example folder/sample.jpg
String

Request header.

This API only uses common request headers. For details, see the Common Request Headers document.
In addition to common headers, the following headers need to be provided:
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 or Not
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). If left blank, no image processing will be performed.
Each item in the rules (json array) has the following specific parameters:
Parameter Name
Type
Required or Not
Description
bucket
String
No
Destination bucket name for storing results, in the format 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 file path and filename of the source file are: /p1/test1.jpg
An absolute path starts with /. For example, when the fileid value is /p2/test2.jpg, it means a file named test2.jpg is stored in the p2 folder.
A path not starting with / is a relative path. For example, when the fileid value is p2/test2.jpg, it means a new p2 folder is created in the p1 folder, and a file named test2.jpg is stored in the p2 folder.
Do not end with /, as this will result in an empty filename.
To overwrite the original image with the repaired one, set the fileid field to <ObjectKey>.
rule
String
Yes
Processing parameters, ci-process = ImageRepair&MaskPic = <MaskPic> & MaskPoly = <MaskPoly>, specific parameter descriptions are in the table below
The following are the relevant parameters for image restoration:
Parameter Name
Description
Type
Required or Not
ci-process
CI processing capability, image logo removal fixed as ImageRepair
String
Yes
MaskPic
mask (region location to be removed in the image) image address, private images must carry a signature and must undergo URL-safe Base64 encoding. For example, if the mask image is http://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/shuiyin_2.png, the encoded string here is aHR0cDovL2V4YW1wbGVidWNrZXQtMTI1MDAwMDAwMC5jb3MuYXAtZ3Vhbmd6aG91Lm15cWNsb3VkLmNvbS9zaHVpeWluXzIucG5n
String
No
MaskPoly
For example: [[[608, 794], [1024, 794], [1024, 842], [608, 842]],[[1295, 62], [1295, 30], [1597, 32],[1597,64]]]. Enter the coordinates of each point of the polygon in clockwise order. Each polygon: [[x1, y1], [x2, y2]...], in the form of a 3D matrix (multiple polygons: [polygon1, polygon2]) or a 2D matrix (single polygon), and required to pass through URL-safe Base64 encoding. When MaskPoly is filled in simultaneously with MaskPic, the value of MaskPic takes precedence.
String
No

Request body.

The request has no request body.

Response

Response Headers

This API returns common response headers. For details, see the Common Response Headers document.

Response Body

The response body returns with a content-type of application/xml. 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
Type
Description
Key
String
Original image filename
Location
String
Image path
The content of the ProcessResults node
Node Name (Keyword)
Parent Node
Description
Type
Object
ProcessResults
The processing result of each image
Container
The content of the Object node
Node Name (Keyword)
Parent Node
Description
Type
Key
Object
Repaired image file name
String
Location
Object
Repaired image link
String
ETag
Object
Repaired image ETag value
String
Size
Object
Image size
Int

Examples

Request

POST /filename.jpg?image_process HTTP/1.1
Host: examplebucket-1250000000.cos.ap-chengdu.myqcloud.com
Date: Wed, 28 Oct 2015 20:32:00 GMT
Authorization: Auth String
Pic-Operations: {"rules":[{"fileid":"bigpic_process.jpg","rule":"ci-process=ImageRepair&MaskPic=aHR0cDovL3BldGVyLWd6LTEyNTE3MDQ3MDguY29zLmFwLWd1YW5nemhvdS5teXFjbG91ZC5jb20vcGljX21hc2suanBn"}]}
Content-Length: 0

Response

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

<UploadResult>
<OriginalInfo>
<Key>456.jpeg</Key>
<Location>examplebucket-1250000000.cos.ap-chongqing.myqcloud.com/456.jpeg</Location>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>bigpic_process.jpeg</Key>
<Location>examplebucket-1250000000.cos.ap-chongqing.myqcloud.com/bigpic_process.jpeg</Location>
<Format/>
<Size>288132</Size>
<ETag>"fa2a3d6081c1037f154401a64eec4b19"</ETag>
</Object>
</ProcessResults>
</UploadResult>

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback