2026-07-01 16:20:05 +08:00
---
description : Expand an image canvas with AI outpainting, extending it in any direction and filling new areas to match the original.
---
2026-07-11 13:01:55 +08:00
# AI Canvas Expand {#ai-canvas-expand}
2026-06-08 11:52:28 +08:00
Expand the canvas of an image with AI-powered fill (outpainting). Extends the image in any direction and fills the new areas with AI-generated content that matches the existing image.
2026-07-11 13:01:55 +08:00
## API Endpoint {#api-endpoint}
2026-06-08 11:52:28 +08:00
2026-06-21 00:12:59 +08:00
`POST /api/v1/tools/image/ai-canvas-expand`
2026-06-08 11:52:28 +08:00
**Processing:** Asynchronous (returns 202, poll `/api/v1/jobs/{jobId}/progress` for status via SSE)
**Model bundle:** `object-eraser-colorize` (1-2 GB)
2026-07-11 13:01:55 +08:00
## Parameters {#parameters}
2026-06-08 11:52:28 +08:00
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| file | file | Yes | - | Image file (multipart) |
| extendTop | integer | No | `0` | Pixels to extend at the top |
| extendRight | integer | No | `0` | Pixels to extend at the right |
| extendBottom | integer | No | `0` | Pixels to extend at the bottom |
| extendLeft | integer | No | `0` | Pixels to extend at the left |
| tier | string | No | `"balanced"` | Quality tier: `fast` , `balanced` , `high` |
| format | string | No | `"auto"` | Output format: `auto` , `png` , `jpg` , `jpeg` , `webp` , `tiff` , `gif` , `avif` , `heic` , `heif` , `jxl` |
| quality | integer | No | `95` | Output quality (1-100) |
At least one extend direction must be greater than 0.
2026-07-11 13:01:55 +08:00
## Example Request {#example-request}
2026-06-08 11:52:28 +08:00
```bash
2026-06-21 00:12:59 +08:00
curl -X POST http://localhost:1349/api/v1/tools/image/ai-canvas-expand \
2026-06-08 11:52:28 +08:00
-F "file=@photo.jpg" \
-F 'settings={"extendTop":200,"extendBottom":200,"extendLeft":100,"extendRight":100,"tier":"balanced"}'
```
2026-07-11 13:01:55 +08:00
## Response {#response}
2026-06-08 11:52:28 +08:00
2026-07-11 13:01:55 +08:00
### Initial Response (202 Accepted) {#initial-response-202-accepted}
2026-06-08 11:52:28 +08:00
```json
{
"jobId" : "a1b2c3d4-e5f6-7890-abcd-ef1234567890" ,
"async" : true
}
```
2026-07-11 13:01:55 +08:00
### Progress (SSE at `/api/v1/jobs/{jobId}/progress`) {#progress-sse-at-api-v1-jobs-jobid-progress}
2026-06-08 11:52:28 +08:00
```
event: progress
data: {"phase":"processing","stage":"Expanding canvas...","percent":50}
```
2026-07-11 13:01:55 +08:00
### Final Result (via SSE) {#final-result-via-sse}
2026-06-08 11:52:28 +08:00
```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
}
}
```
2026-07-11 13:01:55 +08:00
## Notes {#notes}
2026-06-08 11:52:28 +08:00
- Requires the `object-eraser-colorize` model bundle to be installed (1-2 GB).
- Uses LaMa-based outpainting to generate content for the expanded regions.
- The `tier` parameter trades speed for quality: `fast` produces results quickly with potential artifacts, `high` takes longer but produces smoother, more coherent fills.
- Extend values are in pixels. The final image dimensions will be: original width + extendLeft + extendRight by original height + extendTop + extendBottom.
- For non-browser-previewable output formats (HEIC, JXL, TIFF), a WebP preview is generated alongside the main output.
- Supports HEIC/HEIF, RAW, TGA, PSD, EXR, and HDR input formats via automatic decoding.