Advanced ID Photo API

Try on PicWish

Create advanced ID photos with custom dimensions, background colors, face-position constraints, beauty enhancement, outfit changes, watermarked preview, and layout output. It works for ID photo specification, background adjustment, outfit replacement, and printable layouts, with async and sync request modes.

The result image URL is valid for 1 hour. Please download and store it promptly.

Authentication

Every API request must include your API Key in the X-API-KEY request header. Send it with each request exactly as shown in the examples and parameter descriptions.

X-API-KEY: YOUR_API_KEY

Create an advanced ID photo task

POST /api/tasks/visual/external/idphoto

Body Parameters

image_file file optional

Image file. Supports jpg, jpeg, bmp, png, webp, tiff, bitmap. Either image_file or image_url. Priority: image_file>image_url. Image size <15MB, max resolution 4096x4096

For image upload requirements, see Guidelines and Limits #7.

image_url string optional

Image download URL. Supports HTTP and OSS protocols, max 512 characters, download timeout 10s

last_id string optional

Reuse last task input. image_id from task return (not task_id), if provided, image input can be omitted

sync integer optional

Synchronous/Asynchronous. Default: 0.

  • 0: Return a task ID asynchronously;
  • 1: Return the processed result synchronously.
size string optional

ID photo size. The original image size is used by default. Use {width}x{height}, for example 300x400, with a lowercase x separator. Each pixel value must be between 100 and 2000.

format string optional

Output format. Default: png.

  • png: Return an image with a transparent background;
  • jpg: Return an image with a white background.
return_type integer optional

Result return format. Default: 1.

  • 1: Return an image URL;
  • 2: Return a Base64-encoded string.
spec_id integer optional

Specification ID. Specification includes size, background color, face size, file size. For specifications, see Guidelines and Limits #8.

dpi integer optional

Resolution DPI. Min 10, max 1000

px_width integer optional

Pixel width. Can pass (px_width, px_height) or (mm_width, mm_height), default (295, 413), <1800 pixels

px_height integer optional

Pixel height. Used with px_width, <1800 pixels

mm_width integer optional

Millimeter width. Used with mm_height, <180mm

mm_height integer optional

Millimeter height. Used with mm_width, <180mm

change_bg integer optional

Whether to cutout and change background. Default: 1.

  • 0: Keep the original background;
  • 1: Remove and replace the background.
bg_color string optional

Background color. Hex format, common colors: white FFFFFF, red FF0000, blue 438EDB, default white

bg_color2 string optional

Gradient background color. Hex format, background gradients from top bg_color to bottom bg_color2, default empty

face_width integer optional

Face width. Face width (pixels)

min_face_width integer optional

Minimum face width. Minimum face width (pixels)

max_face_width integer optional

Maximum face width. Maximum face width (pixels)

face_height integer optional

Face height. Face height (pixels)

min_face_height integer optional

Minimum face height. Minimum face height (pixels)

max_face_height integer optional

Maximum face height. Maximum face height (pixels)

head_top integer optional

Head top distance. Distance from head top to top edge (pixels)

min_head_top integer optional

Minimum head top. Minimum distance from head top (pixels)

max_head_top integer optional

Maximum head top. Maximum distance from head top (pixels)

chin_top integer optional

Chin top distance. Distance from chin to top edge (pixels)

min_chin_top integer optional

Minimum chin top. Minimum distance from chin (pixels)

max_chin_top integer optional

Maximum chin top. Maximum distance from chin (pixels)

eyes_top integer optional

Eyes top distance. Distance from eyes to top edge (pixels)

min_eyes_top integer optional

Minimum eyes top. Minimum distance from eyes (pixels)

max_eyes_top integer optional

Maximum eyes top. Maximum distance from eyes (pixels)

auto_bright integer optional

Auto brighten. Default: 0.

  • 0: Disable auto brightness;
  • 1: Enable auto brightness.
bright_factor number optional

Brightness intensity. [0, 1], brightness coefficient

auto_smooth integer optional

Auto smooth skin. Default: 0.

  • 0: Disable auto smoothing;
  • 1: Enable auto smoothing.
smooth_factor number optional

Smoothing intensity. [0, 1], smoothing coefficient

auto_thin_face integer optional

Auto slim face. Default: 0.

  • 0: Disable auto face slimming;
  • 1: Enable auto face slimming.
thin_face_factor number optional

Face slimming intensity. [0, 1], face slimming coefficient

auto_sharp integer optional

Auto sharpen. Default: 0.

  • 0: Disable auto sharpening;
  • 1: Enable auto sharpening.
sharp_factor number optional

Sharpening intensity. [0, 1], sharpening coefficient

clothes_id string optional

Clothing template ID. man_1~man_20, woman_1~woman_20, child_1~child_10, default empty. For clothing templates, see Guidelines and Limits #9.

preview integer optional

Preview only. Default: 0.

  • 0: Return the final result;
  • 1: Return a watermarked preview without consuming credits.
quality integer optional

Compression quality. [1, 100], larger value means larger file size

min_file_size integer optional

Target minimum size (Bytes). [0, inf], e.g. 10240 means min file size 10KB, only takes effect when quality is empty, default empty

max_file_size integer optional

Target maximum size (Bytes). [0, inf], only takes effect when quality is empty, default empty

add_label integer optional

Add label. Default: 0.

  • 0: Do not add a label;
  • 1: Add a label below the ID photo.
label_text string optional

Label text. Label content at bottom, default empty

label_height integer optional

Label height. Label height at bottom (pixels)

layout integer optional

Layout. Default: 0.

  • 0: Do not return a layout;
  • 1: Return a layout result.
layout_vertical integer optional

Layout direction. Default: 0.

  • 0: Use a horizontal layout;
  • 1: Use a vertical layout.
layout_size string optional

Paper size. Default: 5inch.

  • 5inch: Five-inch paper;
  • 6inch: Six-inch paper.
layout_bg_color string optional

Canvas background color. Hex format, e.g. white FFFFFF, default gray

layout_qr_code_data string optional

QR code data. Layout additional QR code data, default empty

layout_qr_code_size integer optional

QR code size. Layout additional QR code size in pixels

layout_label_text string optional

Canvas label text. Layout additional text, use \n for line breaks, default empty

Return Parameters

status number

HTTP response status code. See Status Code Definitions.

  • 200: Request succeeded;
  • Non-200: Request failed.
message string

API response message. If the task fails, refer to this field or contact support.

data.task_id string

Advanced ID photo task ID used for polling.

status number

HTTP response status code. See Status Code Definitions.

  • 200: Request succeeded;
  • Non-200: Request failed.
message string

API response message. If the task fails, refer to this field or contact support.

data.task_id string

Task ID. If processing fails, contact support with this task_id.

data.image_id string

The image_id returned from the task, not the task_id. Use it as last_id to reuse the image in the next request.

data.created_at integer

Task creation timestamp.

data.processed_at integer

Timestamp when task processing started.

data.completed_at integer

Task completion timestamp.

data.image string

Download URL or base64 data of the processed ID photo result. URL results are valid for 1 hour.

data.progress number

Task progress.

  • 100: Processing is complete.
data.return_type number

Result return method.

data.state number

Task status. See Status Code Definitions.

  • 1: Succeeded;
  • > 1: Processing;
  • < 0: Failed;
  • -7: Invalid image file.
data.state_detail string

Detailed task status.

Query advanced ID photo result

For asynchronous requests, poll the result once every 1 second. The maximum polling duration for this API is 60 seconds; if the total polling time exceeds this without a result, treat it as a timeout failure.

GET /api/tasks/visual/external/idphoto/{task_id}

Path Parameters

task_id string required

Task ID returned after creating an advanced ID photo task. Use it to query the processing result.

Return Parameters

status number

HTTP response status code. See Status Code Definitions.

  • 200: Request succeeded;
  • Non-200: Request failed.
message string

API response message. If the task fails, refer to this field or contact support.

data.task_id string

Task ID. If processing fails, contact support with this task_id.

data.image_id string

The image_id returned from the task, not the task_id. Use it as last_id to reuse the image in the next request.

data.created_at integer

Task creation timestamp.

data.processed_at integer

Timestamp when task processing started.

data.completed_at integer

Task completion timestamp.

data.image string

Download URL or base64 data of the processed ID photo result. URL results are valid for 1 hour.

data.progress number

Task progress.

  • 100: Processing is complete.
data.return_type number

Result return method.

data.state number

Task status. See Status Code Definitions.

  • 1: Succeeded;
  • > 1: Processing;
  • < 0: Failed;
  • -7: Invalid image file.
data.state_detail string

Detailed task status.

Guidelines and Limits

  1. The result image URL is generally valid for 1 hour. Please download and store it promptly.

  2. HTTP status 200 means the HTTP request succeeded, not that advanced ID photo generation succeeded. Check data.state for the task result. See Status Code Definitions.

  3. When passing URLs as parameters, follow URL encoding standards to prevent parameter parsing issues.

  4. Either image_file or image_url is required, and image_file has higher priority when both are sent. You can also provide last_id to reuse the previous task input and omit the image input.

  5. Standard ID photo costs 6 credits per request; outfit change with clothes_id costs 15 credits; enabling any beauty enhancement adds 8 credits; layout=1 adds 5 credits; preview=1 returns a watermarked preview and consumes no credits.

  6. Use spec_id for preset ID photo specifications, or pass px_width/px_height or mm_width/mm_height. Pixel values must be less than 1800, millimeter values less than 180, and dpi must be between 10 and 1000.

  7. Uploaded images must meet the following format, resolution, and file size limits.

    FormatResolutionSize
    jpg, jpeg, bmp, png, webp, tiff, bitmapUp to 4096 x 4096Up to 15MB
  8. ID Photo Specification List

    spec_id Category Title Size(mm) Size(px) DPI Color Requirement
    1101 Common Small 1 Inch 22x32 260x378 300 No Requirement
    1102 Common 1 Inch 25x35 295x413 300 No Requirement
    1103 Common Large 1 Inch 33x48 390x567 300 No Requirement
    1104 Common Small 2 Inch 35x45 413x531 300 No Requirement
    1105 Common 2 Inch 35x49 413x579 300 No Requirement
    1106 Common Large 2 Inch 35x53 413x626 300 No Requirement
    1107 Common 3 Inch 55x84 649x991 300 No Requirement
    1108 Common 4 Inch 76x102 898x1205 300 No Requirement
    1109 Common 5 Inch 89x127 1051x1500 300 No Requirement
    2101 Government Social Security Card 26x32 358x441 350 White
    2102 Government ID Card 26x32 358x441 350 White
    2103 Government Residence Permit 26x32 358x441 350 White
    2201 Government Health Certificate (1 Inch) 25x35 295x413 300 Blue, White
    2202 Government Health Certificate (Small 2 Inch) 35x45 413x531 300 Blue, White
    2203 Government Medical Insurance Card 26x32 358x441 300 White
    2301 Government Driver's License (Small 1 Inch) 22x32 260x378 300 White
    2401 Government Veteran Preferential Treatment Card 30x37 352x440 300 White
    3101 Visa Brazil Visa 40x50 472x590 300 White
    3102 Visa Iceland Visa 40x50 472x590 300 White
    3103 Visa Argentina Visa 40x40 472x472 300 White
    3105 Visa South Korea Visa 35x45 413x531 300 White
    3106 Visa Kenya Visa 50x50 590x590 300 White
    3107 Visa Malaysia Visa 35x45 413x531 300 White
    3108 Visa USA Visa 51x51 602x602 300 White
    3109 Visa Japan Visa 45x45 531x531 300 White
    3110 Visa Universal Visa 35x45 413x531 300 White
    3111 Visa Thailand Visa 35x45 413x531 300 White
    3112 Visa New Zealand Visa 35x45 413x531 300 White
    3113 Visa Italy Visa 35x45 413x531 300 White
    3114 Visa Israel Visa 51x51 602x602 300 White
    3115 Visa India Visa 51x51 602x602 300 White
    3116 Visa Vietnam Visa 35x45 413x531 300 Blue, Red, White
    3117 Visa Laos Visa 51x51 602x602 300 White
    3118 Visa France Visa 35x45 413x531 300 White
    3119 Visa Myanmar Visa 35x45 413x531 300 White
    3120 Visa Canada Visa 35x45 413x531 300 White
    3121 Visa Philippines Visa 51x51 602x602 300 White
    3203 Visa Overseas Passport Application Photo 33x48 389x566 300 White
    3301 Visa Taiwan Entry Permit 35x45 413x531 300 White
    3302 Visa Hong Kong & Macau Permit 33x48 389x566 300 White
    4101 Student Enrollment Photo (2 Inch) 35x49 413x578 300 Blue, Red, White
    4102 Student Enrollment Photo (1 Inch) 25x35 295x413 300 Blue, Red, White
    4103 Enrollment Hong Kong Student Registration 40x50 472x590 300 White
    4201 Student National Student Registration Photo 26x32 307x378 150 White
    4301 Student University Student Image Collection 41x54 480x640 300 Blue
    4401 Student Graduation Photo 41x54 480x640 300 Blue, White
    5101 Examination National Civil Service Exam (1 Inch) 25x35 295x413 300 Blue, White
    5130 Examination National Civil Service Exam (Small 2 Inch) 35x45 413x531 300 Blue, White
    5131 Examination National Civil Service Exam (2 Inch) 35x49 413x579 300 Blue, White
    5102 Examination Anhui Civil Service Exam 25x35 413x531 300 Blue, White
    5103 Examination Beijing Civil Service Exam 34x45 401x531 300 Blue, White
    5104 Examination Chengdu Civil Service Exam 9x11 102x126 300 Blue, White, Red
    5132 Examination Chengdu Civil Service Exam 25x35 295x413 300 Blue, White
    5105 Examination Gansu Civil Service Exam 35x49 413x579 300 Blue, White
    5106 Examination Guangxi Civil Service Exam 25x35 295x413 300 Blue, White
    5107 Examination Guangzhou Civil Service Exam 35x49 295x413 300 Blue, White
    5108 Examination Guizhou Civil Service Exam 18x25 215x300 300 Blue, White, Red
    5109 Examination Hainan Civil Service Exam 35x45 413x531 300 Blue
    5110 Examination Hebei Civil Service Exam 25x35 295x413 300 Blue, White, Red
    5111 Examination Henan Civil Service Exam 25x35 295x413 300 Blue, White, Red
    5112 Examination Heilongjiang Civil Service Exam 35x45 413x531 300 Blue, White, Red
    5113 Examination Hubei Civil Service Exam 25x35 295x413 300 Blue, White
    5114 Examination Hunan Civil Service Exam 35x45 413x531 300 Blue, White
    5115 Examination Jiangsu Civil Service Exam 35x45 413x531 300 Blue, White
    5116 Examination Jiangxi Civil Service Exam 35x45 413x531 300 Blue, White
    5117 Examination Ningxia Civil Service Exam 35x45 413x531 300 Blue, White
    5118 Examination Qinghai Civil Service Exam 35x45 413x531 300 Blue, White
    5119 Examination Shandong Civil Service Exam 35x49 413x579 300 Blue, White, Red
    5120 Examination Shanxi Civil Service Exam 25x35 295x413 300 Blue, White, Red
    5121 Examination Shanghai Civil Service Exam 13x17 150x200 300 Blue, White
    5122 Examination Shaanxi Civil Service Exam 35x45 413x531 300 Blue, White
    5123 Examination Shenzhen Civil Service Exam 35x53 413x626 300 Blue, White, Red
    5124 Examination Sichuan Civil Service Exam 25x35 295x413 300 Blue, White
    5125 Examination Tibet Civil Service Exam 25x35 295x413 300 Blue, White
    5126 Examination Xinjiang Civil Service Exam 35x45 413x531 300 Blue, White
    5127 Examination Yunnan Civil Service Exam 35x49 413x579 300 Blue, White, Red
    5128 Examination Shanxi Provincial Institution Exam 25x35 295x413 300 White
    5129 Examination Chongqing Civil Service Exam 25x35 295x413 300 Blue, White
    5201 Examination National Exam (2 Inch) 35x45 413x531 300 Blue, White
    5202 Examination National Exam (1 Inch) 25x35 295x413 300 Blue, White
    5203 Examination Gansu Province (National Exam) 25x35 295x413 300 Blue, White, Red
    5204 Examination Jiangxi Province (National Exam) 35x53 413x626 300 Blue, White
    5205 Examination Ningxia (National Exam) 35x45 413x531 300 Blue, White
    5206 Examination Qinghai Province (National Exam) 35x45 413x531 300 Blue, White
    5207 Examination Shanghai (National Exam) 35x53 413x626 300 Blue
    5301 Examination Adult College Entrance Exam 40x54 480x640 300 Blue
    5302 Examination Adult Self-study Exam 40x54 480x640 300 Blue, White
    5303 Examination Adult Self-study Exam 25x34 300x400 300 Blue, White
    5401 Examination College Entrance Exam (1 Inch) 25x35 295x413 300 Blue, White
    5402 Examination College Entrance Exam (Small 2 Inch) 35x45 413x531 300 Blue, White
    5403 Examination Shanghai High School Entrance Exam 14x20 168x240 300 Blue, White, Red
    5404 Examination Wuhan University Graduate Exam 13x17 150x200 300 Blue, White, Red
    5405 Examination Graduate Entrance Exam 33x48 390x567 300 Blue, White
    5406 Examination In-service Graduate Exam 35x45 413x531 300 Blue, White
    5501 Examination Mandarin Proficiency Test 33x48 390x567 300 Blue, White, Red
    5502 Examination Business English Exam 35x49 413x579 300 Blue, White
    5503 Examination Degree English 33x48 390x567 300 White
    5504 Examination English AB Level Exam (2 Inch) 33x48 390x567 300 Blue
    5505 Examination English AB Level Exam (144X192) 12x16 144x192 300 Blue, White
    5506 Examination English Level 3 Exam 12x16 295x413 300 Blue
    5507 Examination English CET-4 33x43 390x507 300 Blue, White
    5508 Examination English CET-4 12x16 144x192 300 Blue, White
    5509 Examination English CET-6 12x16 144x192 300 Blue, White
    5510 Examination Self-study Degree Foreign Language Exam 40x54 480x640 300 Blue
    5601 Examination Securities Exam Registration 18x25 215x300 300 Blue, White, Red
    5602 Examination CPA Exam (1 Inch) 25x35 295x413 300 White
    5603 Examination CPA Exam (178x220) 15x19 178x220 300 White
    5701 Examination National Medical Exam 25x35 295x413 300 Blue, White
    5702 Examination Nurse Qualification Exam 35x45 413x531 300 White
    5703 Examination Pharmacist Qualification Exam (1 Inch) 25x35 295x413 300 White
    5801 Examination Computer Level Exam 12x16 144x192 300 White
    5802 Examination Youth Electronic Info Level Exam 35x53 413x626 300 Blue, Red
    5803 Examination Youth Robot Tech Level Exam 35x53 413x626 300 Blue, White
    5901 Examination BIM Skills Level Exam 25x35 295x413 300 White
    5902 Examination Health Professional Tech Qualification Exam (1 Inch) 25x35 295x413 300 White
    5903 Examination Level 1 Fire Engineer Exam 25x35 295x413 300 White
    5904 Examination Nursery Teacher Exam (1 Inch) 25x35 295x413 300 White
    5905 Examination National Judicial Exam 35x53 413x626 300 Blue, White, Red
    5906 Examination Referee Qualification Exam 25x35 295x413 300 Blue
    6101 Qualification Level 2 Constructor Certificate (1 Inch) 25x35 295x413 300 Blue, White
    6102 Qualification Level 2 Constructor Certificate (2 Inch) 35x53 413x626 300 Blue, White
    6103 Qualification Level 1 Constructor 25x35 295x413 300 White
    6201 Qualification Tour Guide License (1 Inch) 25x35 295x413 300 White
    6202 Qualification Tour Guide License (2 Inch) 35x53 413x626 300 White
    6302 Qualification Veterinary Qualification Certificate 19x28 230x334 300 Blue, White
    6303 Qualification Medical Practitioner Certificate (Small 2 Inch) 35x45 413x531 300 White
    6401 Qualification Teacher Qualification Certificate (300x400) 25x34 300x400 300 White
    6501 Qualification Insurance Professional Certificate (210x270) 18x23 210x270 300 White
    6502 Qualification Accounting Certificate (1 Inch) 25x35 295x413 300 White
    6601 Qualification Law Enforcement Certificate 40x54 480x640 300 White
  9. Clothing List - ID Photo Outfits. Download image assets

    Category Clothing ID Image
    Men's Clothing man_1
    Men's Clothing man_2
    Men's Clothing man_3
    Men's Clothing man_4
    Men's Clothing man_5
    Men's Clothing man_6
    Men's Clothing man_7
    Men's Clothing man_8
    Men's Clothing man_9
    Men's Clothing man_10
    Men's Clothing man_11
    Men's Clothing man_12
    Men's Clothing man_13
    Men's Clothing man_14
    Men's Clothing man_15
    Men's Clothing man_16
    Men's Clothing man_17
    Men's Clothing man_18
    Men's Clothing man_19
    Men's Clothing man_20
    Women's Clothing woman_1
    Women's Clothing woman_2
    Women's Clothing woman_3
    Women's Clothing woman_4
    Women's Clothing woman_5
    Women's Clothing woman_6
    Women's Clothing woman_7
    Women's Clothing woman_8
    Women's Clothing woman_9
    Women's Clothing woman_10
    Women's Clothing woman_11
    Women's Clothing woman_12
    Women's Clothing woman_13
    Women's Clothing woman_14
    Women's Clothing woman_15
    Women's Clothing woman_16
    Women's Clothing woman_17
    Women's Clothing woman_18
    Women's Clothing woman_19
    Women's Clothing woman_20
    Children's Clothing child_1
    Children's Clothing child_2
    Children's Clothing child_3
    Children's Clothing child_4
    Children's Clothing child_5
    Children's Clothing child_6
    Children's Clothing child_7
    Children's Clothing child_8
    Children's Clothing child_9
    Children's Clothing child_10