Canvas Resize

Convert an image to a target canvas size. Supports multiple canvas modes and is suitable for multi-platform image adaptation.

Prefer not to code? Upload files and process them in Gitruck Toolbox. Just sign in; results match this API.Open Image Aspect Ratio Converter →

Create Task

Basic Information

ItemValue
Request MethodPOST
Request Path/task/image_canvas_adapt
Content-Typeapplication/json
AuthenticationRaw API key in the Authorization header

Request Body

ParameterTypeRequiredDefaultDescription
file_idstringYes-Uploaded image file ID
canvas_widthnumberNo1080Target canvas width in pixels
canvas_heightnumberNo1920Target canvas height in pixels
canvas_typestringNo"normal"Canvas mode: normal, square, or fit

Request Example

curl -X POST https://api.ai-mcn.tv:10000/task/image_canvas_adapt \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file_id": "537489015178246",
    "canvas_width": 1080,
    "canvas_height": 1920,
    "canvas_type": "normal"
  }'

Success Example

{
  "code": 200,
  "msg": "success",
  "data": {
    "task_id": "537489015178247",
    "task_type": "image_canvas_adapt",
    "status": "queued"
  }
}

Query Task Result

Basic Information

ItemValue
Request MethodGET
Request Path/task/image_canvas_adapt/{task_id}
AuthenticationRaw API key in the Authorization header

Output Result (output_result)

ParameterTypeDescription
file_idstringProcessed image file ID
original_sizestringOriginal size, such as "1920x1080"
target_sizestringTarget size, such as "1080x1920"

Success Example

{
  "code": 200,
  "msg": "success",
  "data": {
    "task_id": "537489015178247",
    "status": "completed",
    "progress": 100,
    "output_result": {
      "file_id": "537489015178248",
      "original_size": "1920x1080",
      "target_size": "1080x1920"
    },
    "create_time": "2026-04-05T08:00:00Z",
    "update_time": "2026-04-05T08:00:03Z"
  }
}

Error Codes

Error CodeHTTP StatusDescriptionResolution
6013400Missing file_idPass the file_id field
6014400File type does not match the taskUpload an image file
6004404File not foundVerify the file_id
6017400The file is not a recognizable image (for example, a web page saved as .jpg, or a file whose header is cut off). It is rejected at task creation; no task is created and nothing is chargedRe-export the image as JPEG / PNG and upload it again
6502401Authentication failedCheck the Authorization header
6202402Insufficient balanceRecharge in the Dashboard
6021—The image data is incomplete or damaged, typically truncated by an interrupted download or upload. The file header is intact, so this can't be detected at task creation (during execution: the task fails and credits are refunded; see error_code in the task result)Re-export the image or use the original, then resubmit