Image Creation
Description
This API is used for ID Photo - Image Creation requests. For specific effects, please refer to the details in the following documentation.
Version
1.0
Image Requirements
Image formats: JPG, PNG
Changelog
Request URL
Production environment: https://openapi.meitu.com/idphoto/business/v1/make
Request Method
POST
The request header type should include: Content-Type:application/json
Permission
Credits cannot be used to pay for API calls. Please visit the MV console to activate this API and purchase or manage resource packages.
Request Parameters
| Parameter Name | Type | Maximum Length | Required | Remarks |
|---|---|---|---|---|
| out_request_id | string | 64 | Yes | External request ID (unique) |
| img_url | string | 200 | No | Image URL (complete URL address, requires urlencode processing) |
| name | string | 20 | Yes | ID photo name (e.g.: One-inch Photo) |
| back_color | string | 7 | Yes | Background color value, e.g.: #357ec2 |
| back_mode | int | - | Yes | Background mode: 0 solid color, 1 top to bottom, 2 outside to inside, 3 inside to outside |
| size_unit | int | - | Yes | Size unit: 1=px, 2=mm, required for custom ID photos |
| sd_width | int | - | Yes | Standard-definition width, unit: px |
| sd_height | int | - | Yes | Standard-definition height, unit: px |
| sd_dpi | int | - | Yes | Standard-definition resolution (dpi) |
| sd_size_min | int | - | Yes | Standard-definition file size, minimum value, unit: kb |
| sd_size_max | int | - | Yes | Standard-definition file size, maximum value, unit: kb |
| hd_dpi | int | - | Yes | High-definition resolution (dpi), generally recommended value: 1000 |
| custom_watermark_vertical | string | 200 | No | Custom vertical watermark identifier (contact Meitu Business for configuration) |
| custom_watermark_transverse | string | 200 | No | Custom horizontal watermark identifier (contact Meitu Business for configuration) |
| face_switch | int | - | No | Face frame switch, 1=enabled, 2=disabled (disabled by default). Face parameters take effect only when enabled |
| face_top | int | - | No | Distance from the top of the head to the top of the image, top, 0≤ face_top < height of the generated ID photo |
| face_width | int | - | No | Face frame width, width, 0<face_width < width of the generated ID photo |
| face_height | int | - | No | Face frame height, height, 0< face_height< height of the generated ID photo |
| mt_check_id | string | 64 | No | If the partner integrates the detection API /idphoto/business/check, the detection identifier returned by this API will be obtained; this identifier can be used in other image creation APIs to skip image upload and detection |
Note:
- One and only one of img_url and mt_check_id must be provided. The API will select the image to be created based on the parameter provided;
- This API has built-in basic image detection capabilities. If the partner has more detailed detection requirements, the detection API /idphoto/business/check can be integrated;
Request Example
{
"back_color": "#00868B",
"back_mode": 3,
"hd_dpi":1000,
"img_url": "https://481598.jpeg",
"name": "295*413",
"out_request_id":"36936",
"sd_dpi": 300,
"sd_height": 35,
"sd_size_max": 6,
"sd_size_min": 2,
"size_unit": 2,
"sd_width": 25,
"mt_generate_id": "72039499999199999"
}Return Value Description
Successful Return Value Description
| Field Name | Type | Example Value | Description |
|---|---|---|---|
| code | int | 100000 | Response status code |
| msg | string | Operation successful | Prompt |
| data | object | Data | |
| data.check_fail_item | string | Unable to recognize, face is obstructed | Image detection failure error information (multiple errors are separated by commas) [Used to prompt the user when image detection fails] |
| data.mt_generate_id | string | 6917420196238201565 | Meitu ID photo generation ID |
| data.sd_photo | string | http://biz-res-pre.zone1.meitudata.com/idphoto-private/1646220627569878737-460912.jpg?xxxxxxxxx | Standard-definition image |
| data.hd_photo | string | http://biz-res-pre.zone1.meitudata.com/idphoto-private/1646220627569878737-460912.jpg?xxxxxxxxx | High-definition image |
| data.typesetting_photo | string | http://biz-res-pre.zone1.meitudata.com/idphoto-private/1646220627569878737-460912.jpg?xxxxxxx | Typesetting image |
Failed Return Value Description
| Field | Type | Description |
|---|---|---|
| data | String | Returned content |
| message | String | Error message |
| code | Int | Error code |
Return Value Example
Successful Request Return Example
Response Status: 200
content-type is application/json; charset=utf-8
{
"code": 100000,
"msg": "Operation successful",
"data": {
"check_fail_msg": "",
"mt_generate_id": "2329351846",
"sd_photo": "http://biz-res-pre.zone1.meitudata.com/i0T242B5B786IvdMEigEjyE8=",
"hd_photo": "http://biz-res-pre.zone1.meitudata.com/oken=MO2HHQCVI6TWO3RGWjyE8=",
"typesetting_photo": "http://biz-res-pre.zone1.meitudata.com/i56fKhjxeTmUYEeG5jEdOM3Y="
},
"log_id": "Z7VX7Aw6pFtQ4md21VCdRlCXp3TByG99"
}Return Status Codes
| Status Code | Description |
|---|---|
| 100000 | Success |
| 100001 | Parameter error |
Error Codes and Information
- For descriptions of billing rules, error codes, msg, and other content related to this API, please refer to Billing & Status Code Description
- For platform-wide error codes, please refer to API Error Codes