May 19, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0
This interface provides image intelligence tailoring based on small programs.
How to call:
POST https://api.weixin.qq.com/cv/img/aicrop?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
img_url | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | string | Error code |
errmsg | string | The error message |
Description File size limit: Less than 2M images support the use of img parameters for real-time upload, but also support the use of img_url parameters to transmit picture addresses, by WeChat background download pictures to identify. The ratios parameter is optional, and if it is empty, the algorithm automatically trims the optimal aspect ratio, and if multiple aspect ratios are provided, separate them with an English comma, "Separate, support up to 5 aspect ratios."
Example 1:
curl -F 'ratios=1,2.35' "http://api.weixin.qq.com/cv/img/aicrop?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN"
Example 2:
curl -F 'img=@test.jpg' -F 'ratios=1,2.35' 'http://api.weixin.qq.com/cv/img/aicrop?access_token=ACCESS_TOCKEN'
{
"errcode": 0,
"errmsg": "ok",
"results": [ //智能裁剪结果
{
"crop_left": 112,
"crop_top": 0,
"crop_right": 839,
"crop_bottom": 727
},
{
"crop_left": 0,
"crop_top": 205,
"crop_right": 965,
"crop_bottom": 615
}
],
"img_size": { //图片大小
"w": 966,
"h": 728
}
}
Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.
openapi.img.aiCrop
Permissions for the img.aiCrop API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
imgUrl | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The structure of img
Property | Type | The default | Required | Description |
---|---|---|---|---|
contentType | string | Is | Data type, incoming MIME Type | |
value | Buffer | Is | File Buffer |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|
Description File size limit: Less than 2M images support the use of img parameters for real-time upload, but also support the use of img_url parameters to transmit picture addresses, by WeChat background download pictures to identify. The ratios parameter is optional, and if it is empty, the algorithm automatically trims the optimal aspect ratio, and if multiple aspect ratios are provided, separate them with an English comma, "Separate, support up to 5 aspect ratios."
{
"errcode": 0,
"errmsg": "ok",
"results": [ //智能裁剪结果
{
"crop_left": 112,
"crop_top": 0,
"crop_right": 839,
"crop_bottom": 727
},
{
"crop_left": 0,
"crop_top": 205,
"crop_right": 965,
"crop_bottom": 615
}
],
"img_size": { //图片大小
"w": 966,
"h": 728
}
}