Feature Description
Tencent Cloud CI uses the AIFaceBeauty API to perform intelligent beauty processing on human faces in images, suitable for social media image beautification or repairing and enhancing human faces after face effect processing, then fusing them back into the original image.
Note:
This interface belongs to a GET request, is a synchronous request method, and requires 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 CI action. Processing during download: In the authorization policy, set action to cos:GetObject, ci:CreateAIFaceBeautifyJob.
Process during upload: Set action to cos:PutObject, ci:CreateAIFaceBeautifyJob in the authorization policy.
Cloud data processing: In the authorization policy, set action to cos:GetObject, cos:PutObject, ci:CreateAIFaceBeautifyJob (Note: GetObject corresponds to the source file resource, and PutObject corresponds to the transferred file resource).
Activating a Service
Using this feature requires enabling Cloud Infinite in advance and binding a bucket. For details, see 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. Generated costs will be charged by Cloud Infinite. For billing details, see Content Recognition. Solutions
Method One: Processing during Download
Request
Original image stored in COS
GET /<ObjectKey>?ci-process=AIFaceBeauty HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Original image from another link
GET /?ci-process=AIFaceBeauty&detect-url=<detect-url> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Processing Parameter Description
|
ObjectKey | object filename, for example: folder/document.jpg. | String | Yes |
ci-process | Cloud Infinite processing capability, image enhancement fixed as AIFaceBeauty. | String | Yes |
strength | Intensity of beauty effects, value range is a floating-point number between 0 and 1, default value is 0.5. | Float | No |
detect-url | You can process any publicly accessible image link by filling in detect-url. If detect-url is not specified, the backend will default to processing ObjectKey. If detect-url is filled in, the backend will process the detect-url link, and there is no need to fill in ObjectKey. http://www.example.com/abc.jpg needs to be url-encoded, and the processed result is http%25253A%25252F%25252Fwww.example.com%25252Fabc.jpg.
| String | No |
ignore-error | When this parameter is set to 1, for scenarios such as file size being too large that cause processing failure, the original image will be returned directly without reporting an error. | Integer | 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
x-cos-request-id: NWFjMzQ0MDZfOTBmYTUwXzZkZV8z****
[pic-content]
The processed image is returned directly in the response body.
Method Two: Processing Upon Upload
Request Syntax
PUT /<ObjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Pic-Operations: <PicOperations>
Request Headers
This API only uses common request headers. For details, see the Common Request Headers document. In addition to the common headers, the following headers need to be provided: |
Pic-Operations | Parameters for image operations | String |
Pic-Operations is a json format string with the following specific parameters:
|
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 not perform image processing. |
Each item in the rules (json array) has the following specific parameters:
|
bucket | String | No | The name of the target bucket 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. Naming rules description: For example, the source file path and name are: /p1/test1.jpg 1. 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. 2. A relative path does 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. 3. Do not end with /, otherwise an empty filename will occur. 4. If you want the repaired image to overwrite the original image, set the fileid field to <ObjectKey>. |
rule | String | Yes | process parameter, fixed as: ci-process=AIFaceBeauty |
Request Body
The request body contains the original image to be super-resolved [Image Content]
Response
Response Headers
Response Body
The response body returns data with a content-type of application/xml, and the specific data content is as follows:
|
UploadResult | None. | Request result. | Container |
The content of UploadResult
|
OriginalInfo | UploadResult | Image information | Container |
ProcessResults | UploadResult | Request processing result | Container |
The content of the OriginalInfo node
|
Key | OriginalInfo | Original image file name | String |
Location | OriginalInfo | Original image path | String |
ETag | OriginalInfo | Original image ETag value | String |
ProcessResults node content:
|
Object | ProcessResults | Processing result of each image | Container |
Object node content:
|
Key | Object | Beauty effect image file name | String |
Location | Object | Beauty effect image link | String |
ETag | Object | Beauty effect image ETag value | String |
Size | Object | Beauty effect image size | Int |
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=AIFaceBeauty"
}]
}
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>ObjectKey</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/filename.jpg</Location>
<ETag>"ed60e3598e6862d8c8443a06acfb2153"</ETag>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>exampleobject</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/exampleobject</Location>
<Format/>
<Size>354256</Size>
<ETag>"521451f63c331becf533e466732c1091"</ETag>
</Object>
</ProcessResults>
</UploadResult>
Method Three: Cloud Data Processing
Request Syntax
POST /<ObjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Pic-Operations: <PicOperations>
Request
Request header.
This API only uses common request headers. For details, see the Common Request Headers document. In addition to the common headers, the following headers need to be provided: |
Pic-Operations | Parameters for image operations | String |
Pic-Operations is a json format string with the following specific parameters:
|
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 not perform image processing. |
Each item in the rules (json array) has the following specific parameters:
|
bucket | String | No | The name of the target bucket 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. Naming rules description: For example, the source file path and name are: /p1/test1.jpg 1. Starts with / is an absolute path. For example, when the fileid value is /p2/test2.jpg, it means a file named test2.jpg is stored in the p2 folder. 2. A relative path does 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. 3. Do not end with /, otherwise an empty filename will occur. 4. If you want the beautified image to overwrite the original image, set the fileid field to <ObjectKey>. |
rule | String | Yes | process parameter, fixed as: ci-process=AIFaceBeauty |
Request Body
The request body contains the original image to be beautified [Image Content]
Response
Response Headers
Response Body
The response body returns data with a content-type of application/xml, and the specific data content is as follows:
|
UploadResult | None. | Request result. | Container |
The content of UploadResult
|
OriginalInfo | UploadResult | Image information | Container |
ProcessResults | UploadResult | Request processing result | Container |
The content of the OriginalInfo node
|
Key | UploadResult.OriginalInfo | Original image file name | String |
Location | UploadResult.OriginalInfo | Original image path | String |
ETag | UploadResult.OriginalInfo | Original image ETag value | String |
ProcessResults node content:
|
Object | UploadResult.ProcessResults | Processing result of each image | Container |
Object node content:
|
Key | UploadResult.ProcessResults.Object | Beauty effect image file name | String |
Location | UploadResult.ProcessResults.Object | Beauty effect image link | String |
ETag | UploadResult.ProcessResults.Object | Beauty effect image ETag value | String |
Size | UploadResult.ProcessResults.Object | image size | Int |
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=AIFaceBeauty"
}]
}
The processed image is stored in the bucket, and the field value of fileid is used 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>ObjectKey</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/filename.jpg</Location>
<ETag>"ed60e3598e6862d8c8443a06acfb2153"</ETag>
</OriginalInfo>
<ProcessResults>
<Object>
<Key>exampleobject</Key>
<Location>examplebucket-1250000000.cos.ap-chengdu.myqcloud.com/exampleobject</Location>
<Format/>
<Size>354256</Size>
<ETag>"521451f63c331becf533e466732c1091"</ETag>
</Object>
</ProcessResults>
</UploadResult>