Search K
Are you an LLM? You can read better optimized documentation at /zh-CN/tools/image/ai-canvas-expand.md for this page in Markdown format
AI Canvas Expand
使用 AI 驱动的填充(外绘)扩展图像画布。向任意方向延伸图像,并用与现有图像匹配的 AI 生成内容填充新区域。
API Endpoint
POST /api/v1/tools/image/ai-canvas-expand
处理方式: 异步(返回 202,通过 SSE 轮询 /api/v1/jobs/{jobId}/progress 获取状态)
模型包: object-eraser-colorize(1-2 GB)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| file | file | 是 | - | 图像文件(multipart) |
| extendTop | integer | 否 | 0 | 顶部要扩展的像素数 |
| extendRight | integer | 否 | 0 | 右侧要扩展的像素数 |
| extendBottom | integer | 否 | 0 | 底部要扩展的像素数 |
| extendLeft | integer | 否 | 0 | 左侧要扩展的像素数 |
| tier | string | 否 | "balanced" | 质量档位:fast、balanced、high |
| format | string | 否 | "auto" | 输出格式:auto、png、jpg、jpeg、webp、tiff、gif、avif、heic、heif、jxl |
| quality | integer | 否 | 95 | 输出质量(1-100) |
至少有一个扩展方向必须大于 0。
Example Request
bash
curl -X POST http://localhost:1349/api/v1/tools/image/ai-canvas-expand \
-F "[email protected]" \
-F 'settings={"extendTop":200,"extendBottom":200,"extendLeft":100,"extendRight":100,"tier":"balanced"}'Response
Initial Response (202 Accepted)
json
{
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"async": true
}Progress (SSE at /api/v1/jobs/{jobId}/progress)
event: progress
data: {"phase":"processing","stage":"Expanding canvas...","percent":50}Final Result (via SSE)
json
{
"phase": "complete",
"percent": 100,
"result": {
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"downloadUrl": "/api/v1/download/{jobId}/photo_extended.png",
"previewUrl": "/api/v1/download/{jobId}/preview.webp",
"originalSize": 300000,
"processedSize": 520000
}
}Notes
- 需要安装
object-eraser-colorize模型包(1-2 GB)。 - 使用基于 LaMa 的外绘为扩展区域生成内容。
tier参数在速度和质量之间权衡:fast能快速产出结果但可能有瑕疵,high耗时更长但能产出更平滑、更连贯的填充。- 扩展值以像素为单位。最终图像尺寸将为:原始宽度 + extendLeft + extendRight 乘以 原始高度 + extendTop + extendBottom。
- 对于浏览器无法预览的输出格式(HEIC、JXL、TIFF),会在主输出旁生成一个 WebP 预览。
- 通过自动解码支持 HEIC/HEIF、RAW、TGA、PSD、EXR 和 HDR 输入格式。
