Task: ID Photo
Short description: Use the ID photo API to generate a standard-sized ID photo.
Overview
- Method:
POST - Path:
/task/pic/idphoto - Content-Type:
multipart/form-data
Authentication
- Header:
Authorization: Bearer <token>
Request Example
Form Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| image_file | file | No | Source image file (binary), mutually exclusive with image_url |
| image_url | string | No | Source image URL, mutually exclusive with image_file |
| size | string | No | ID photo size in {width}x{height} format, e.g. 300x400; pixel range 100~2000 |
| format | string | No | Output format: png=transparent background, jpg=white background, default png |
| sync | integer | No | Whether to wait for the result: 0=async (default), 1=sync |
| bg_color | string | No | JPG background color in RRGGBB format, e.g. FFFFFF; only effective when format=jpg |
| callback_url | string | No | Callback URL for notifications |
curl Example
bash
curl -X POST "https://api.gpt.ge/task/pic/idphoto" \
-H "Authorization: Bearer sk-xxxx" \
-F "image_url=https://example.com/portrait.png" \
-F "size=300x400" \
-F "format=jpg" \
-F "bg_color=FFFFFF" \
-F "sync=1"JavaScript (fetch) Example
javascript
const formData = new FormData();
formData.append('image_url', 'https://example.com/portrait.png');
formData.append('size', '300x400');
formData.append('format', 'jpg');
formData.append('bg_color', 'FFFFFF');
formData.append('sync', '1');
fetch('https://api.gpt.ge/task/pic/idphoto', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-xxxx'
},
body: formData
}).then(r => r.json()).then(console.log);Python (requests) Example
python
import requests
url = 'https://api.gpt.ge/task/pic/idphoto'
headers = {
'Authorization': 'Bearer sk-xxxx'
}
files = {
'image_url': (None, 'https://example.com/portrait.png')
}
data = {
'size': '300x400',
'format': 'jpg',
'bg_color': 'FFFFFF',
'sync': '1'
}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())Response Example (200)
json
{
"status": 200,
"data": {
"completed_at": 1742670627,
"created_at": 1742670626,
"download_time": 488,
"err_info": "",
"foreground_rect": {
"x": 133,
"y": 110,
"width": 604,
"height": 952
},
"image": "https://wxtechsz.oss-cn-shenzhen.aliyuncs.com/tasks/output/idphoto/3b950563-e53f-4036-a581-5ac04d0829b3-image.png",
"image_height": 400,
"image_width": 300,
"output_type": 2,
"processed_at": 1742670626,
"progress": 100,
"result_type": "object",
"return_type": 1,
"state": 1,
"state_detail": "Complete",
"task_id": "3b950563-e53f-4036-a581-5ac04d0829b3",
"time_elapsed": 384.54998779296875,
"type": "auto"
}
}Note: This endpoint uses
multipart/form-datato upload the image. Submit eitherimage_urlorimage_file, not both.bg_coloris only effective whenformat=jpg.