Files
SnapOtter/apps/docs/zh-CN/tools/image/ai-canvas-expand.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

3.0 KiB
Raw Blame History

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
使用 AI 外绘扩展图像画布,向任意方向延伸并填充与原图匹配的新区域。 1b00db4ed40d human a0402622243c

AI Canvas Expand

使用 AI 驱动的填充(外绘)扩展图像画布。向任意方向延伸图像,并用与现有图像匹配的 AI 生成内容填充新区域。

API Endpoint

POST /api/v1/tools/image/ai-canvas-expand

处理方式: 异步(返回 202,通过 SSE 轮询 /api/v1/jobs/{jobId}/progress 获取状态)

模型包: object-eraser-colorize1-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" 质量档位:fastbalancedhigh
format string "auto" 输出格式:autopngjpgjpegwebptiffgifavifheicheifjxl
quality integer 95 输出质量(1-100

至少有一个扩展方向必须大于 0。

Example Request

curl -X POST http://localhost:1349/api/v1/tools/image/ai-canvas-expand \
  -F "file=@photo.jpg" \
  -F 'settings={"extendTop":200,"extendBottom":200,"extendLeft":100,"extendRight":100,"tier":"balanced"}'

Response

Initial Response (202 Accepted)

{
  "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)

{
  "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 输入格式。