AI MediaKit
参数 | 类型 | 是否必选 | 示例值 | 描述 |
Authorization | String | 是 | Bearer {Your_API_Key} |
参数 | 类型 | 是否必选 | 示例值 | 描述 |
image_url | String | 是 | https://example.com/source.jpg | 待处理的图片 URL。
|
crop_mode | String | 否 | custom | 裁剪模式,决定了裁剪的行为方式及所需参数。默认为 directional。
|
output_format | String | 否 | png | 输出图片的格式。默认为 original(保持原图格式)。可选值:png、jpeg、webp。 注意:对于内切圆裁剪(crop_mode 为 circle),为确保背景透明,建议将输出格式设置为 png 或 webp。若输出为 jpeg,非圆形区域将被填充为白色。 |
queue_id | String | 否 | q00a9731598092652e4a95292434198 | 任务提交的目标队列 ID。如不传,默认会使用系统自动创建的队列 ID。您可以将不同业务或优先级的任务提交到不同的队列,以实现按队列对应的项目进行分账。您可以在 AI MediaKit 控制台队列管理页面创建和管理队列,系统会自动分配一个队列 ID。详情请参考项目与队列管理。 |
方向裁剪参数(当 crop_mode 为 directional 时生效) | | | | |
crop_width | Integer | 否 | 800 | 裁剪后图像的目标宽度,单位为 px。当 crop_mode 为 directional 时,必须提供 crop_width 和 crop_height,且二者不能同时为 0。 若 crop_width 设为 0,则宽度将根据 crop_height 按原图比例自适应。 |
crop_height | Integer | 否 | 600 | 裁剪后图像的目标高度,单位为 px。当 crop_mode 为 directional 时,必须提供 crop_width 和 crop_height,且二者不能同时为 0。 若 crop_height设为 0,则高度将根据 crop_width 按原图比例自适应。 |
crop_position | String | 否 | center | 裁剪区域的位置,默认为 center。可选值:
|
定向裁剪参数(当 crop_mode 为 origin 时生效) | | | | |
crop_width | Integer | 否 | 400 | 裁剪后图像的目标宽度,单位为 px。当 crop_mode 为 origin 时必填。 |
crop_height | Integer | 否 | 300 | 裁剪后图像的目标高度,单位为 px。当 crop_mode 为 origin 时必填。 |
origin_gravity | String | 否 | northwest | 裁剪的锚点(起始点),默认为 northwest (左上角)。可选值:
|
origin_x | Integer | 否 | 50 | 裁剪区域相对于锚点的水平偏移量,单位为 px。当 crop_mode 为 origin 时必填。正值向右,负值向左。 |
origin_y | Integer | 否 | 100 | 裁剪区域相对于锚点的垂直偏移量,单位为 px。当 crop_mode 为 origin 时必填。正值向下,负值向上。 |
自定义裁剪参数(当 crop_mode 为 custom 时生效) | | | | |
custom_x1 | Integer | 否 | 100 | 裁剪区域左上角的横坐标(X 轴),单位为 px。当 crop_mode 为 custom 时必填。 |
custom_y1 | Integer | 否 | 150 | 裁剪区域左上角的纵坐标(Y 轴),单位为 px。当 crop_mode 为 custom 时必填。 |
custom_x2 | Integer | 否 | 400 | 裁剪区域右下角的横坐标(X 轴),单位为 px。当 crop_mode 为 custom 时必填。 |
custom_y2 | Integer | 否 | 350 | 裁剪区域右下角的纵坐标(Y 轴),单位为 px。当 crop_mode 为 custom 时必填。 |
参数 | 类型 | 描述 |
success | Boolean | 任务是否成功。
|
result | Object | |
error | Object | |
task_id | String | 任务的唯一标识。 |
task_type | String | 任务类型。 |
request_id | String | 本次 API 请求的唯一标识,可用于问题排查。 |
expires_at | Integer | 任务结果的过期时间戳(Unix Time,单位:秒)。仅当任务成功且有结果时返回。 |
queue_id | String | 任务提交的目标队列 ID。 |
参数 | 类型 | 描述 |
image_url | String | 处理后的图片文件下载地址。该地址的有效期为 24 小时,请务必及时保存产物。 |
image_size | Integer | 生成图像的大小,单位为字节。 |
image_format | String | 生成图像的格式,例如:png。 |
image_width | Integer | 生成图像的宽度,单位为 px。 |
image_height | Integer | 生成图像的高度,单位为 px。 |
参数 | 类型 | 描述 |
code | String | |
type | String | 错误的宏观类型。例如:BadRequest。 |
message | String | 对错误的详细描述,可用于开发调试。 |