Skip to content

图像扩展(Outpainting)

向图片的四个方向扩展指定像素,由 AI 自动补全扩展区域的内容,使图像自然延伸。

基本信息

项目
接口路径POST /image/outpainting
所需 Scopeoutpainting*

| 任务类型 | 异步,返回 taskId |


请求参数

json
{
  "requestId": "可选,调用方自定义唯一 ID",
  "url": "原图的公开 HTTPS URL(必填)",
  "leftExpand": 100,
  "rightExpand": 100,
  "topExpand": 100,
  "bottomExpand": 100,
  "meta": "可选的内容描述提示"
}

参数说明

参数类型必填说明
requestIdstring调用方请求 ID,用于幂等去重
urlstring原图的公开 HTTPS URL
leftExpandinteger向左扩展的像素数
rightExpandinteger向右扩展的像素数
topExpandinteger向上扩展的像素数
bottomExpandinteger向下扩展的像素数
metastring对扩展区域内容的文字描述,有助于引导 AI 生成

四个方向至少提供一个非零值。


请求示例

向右下各扩展 200px:

bash
curl -s -X POST \
  -H "Authorization: Bearer $TUSEN_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/photo.jpg",
    "rightExpand": 200,
    "bottomExpand": 200
  }' \
  "https://magiqsight.com/openapi/v1/image/outpainting"

四方向均匀扩展:

bash
curl -s -X POST \
  -H "Authorization: Bearer $TUSEN_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/photo.jpg",
    "leftExpand": 100,
    "rightExpand": 100,
    "topExpand": 100,
    "bottomExpand": 100,
    "meta": "蓝天白云的户外场景"
  }' \
  "https://magiqsight.com/openapi/v1/image/outpainting"

响应示例

json
{
  "code": 0,
  "data": {
    "requestId": "req_abc123",
    "taskId": "task_xyz"
  },
  "msg": ""
}

获得 taskId 后,通过 GET /tasks/{taskId} 轮询结果。

妙图设计 API Beta