Photo Cropping and Enhancement API

Try on PicWish

AI intelligently detects image edges, crops the subject or document area, corrects orientation, and can enhance text or remove product backgrounds according to the selected enhancement type. It supports 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 a photo cropping and enhancement task

POST /api/tasks/visual/correction

Body Parameters

image_url string optional

Source image URL. Use either image_url or image_file. If this parameter is present, the other image source parameter must be empty.

one required
image_file file optional

Source image file as binary data. Use either image_file or image_url. If this parameter is present, the other image source parameter must be empty.

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

sync integer optional

Whether to wait for the result and return it immediately. 0 means async mode and returns task_id for later polling; 1 means sync mode and waits for the result. Results are kept for up to 1 hour.

type integer optional

Enhancement type. 0 = crop and correct orientation for text/document images; 1 = text enhancement for text/document images (default); 2 = text enhancement plus crop and orientation correction for text/document images; 3 = crop and correct orientation for product images; 4 = crop and correct orientation plus background removal for product images.

return_type integer optional

Result return format. 1 returns an image URL; 2 returns a base64-encoded image; 3 returns binary image data and is only available for synchronous requests.

Return Parameters

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

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

data.task_id string

Async photo cropping and enhancement task ID returned after the task is created. Use it to query the result later.

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

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

data.task_id string

Photo cropping and enhancement task ID.

data.created_at string

Task creation time as a Unix timestamp string.

data.processed_at string

Task processing start time as a Unix timestamp string.

data.completed_at string

Task completion time as a Unix timestamp string.

data.image string

Result image URL or base64 data, depending on return_type. URL results are valid for 1 hour.

data.progress number

Task progress. 100 means processing is complete.

data.state number

Task status code. 1 means succeeded, greater than 1 means processing, and less than 0 means failed. See Status Code Definitions.

Query photo cropping and enhancement result

GET /api/tasks/visual/correction/{task_id}

Path Parameters

task_id string required

Photo cropping and enhancement task ID returned after creating an async task. Use it to query the processing result.

Return Parameters

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

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

data.task_id string

Photo cropping and enhancement task ID. If the task fails, contact support with this task_id.

data.created_at string

Task creation time as a Unix timestamp string.

data.processed_at string

Task processing start time as a Unix timestamp string.

data.completed_at string

Task completion time as a Unix timestamp string.

data.image string

Result image URL or base64 data, depending on return_type. URL results are valid for 1 hour.

data.progress number

Task progress. 100 means processing is complete.

data.state number

Task status code. 1 means succeeded, greater than 1 means processing, and less than 0 means failed. See Status Code Definitions.

Guidelines and Limits

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

  2. HTTP status 200 indicates that the HTTP request succeeded, not necessarily that the image task succeeded. See Status Code Definitions for details.

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

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

    FormatResolutionSize
    jpg, jpeg, bmp, png, webp, tiff, tif, bitmap, raw, rgb, jfif, lzwUp to 4096 x 4096Up to 20MB