Image Inpainting
studio-inpaintRemove objects from images and fill the gap with photorealistic detail. Accepts bbox, RLE, and polygon masks.
The Inpainting service combines all your masks, expands them slightly (dilate_px, default 15), rebuilds the layout under the masked area, and refines the texture with optional prompt guidance for a photorealistic fill. The result is feathered back into the original (feather_px, default 45) so the transition is invisible. Images larger than 4096 px are resized automatically.
Inpaint Image
/v1/proxy/studio-inpaintRemove objects from image (async)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
imageUrl | string | required | Public URL of the source image |
masks | array | required | Mask definitions: [{type: 'bbox'|'rle'|'polygon', data: ...}] |
dilate_px | integer | optional | Expand masks by N pixels (default: 15) |
prompt | string | optional | Custom prompt to steer the fill |
negative_prompt | string | optional | Custom negative prompt |
feather_px | integer | optional | Gaussian feather for blending (default: 45) |
curl -X POST https://api.cn8.io/v1/proxy/studio-inpaint \
-H "X-API-Key: <cn8_api_key>" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"https://example.com/file","masks":["value"]}'{
"status": "success",
"data": {
"url": "https://s3.../inpainted_output.jpg",
"original_size": { "width": 1920, "height": 1080 },
"masks_applied": 2
},
"usage": { "units": 1, "unit_type": "item" }
}
Typical Workflow
- Upload image via POST /v1/upload-media
- Segment objects via POST /v1/proxy/studio-segment (auto mode)
- User selects unwanted objects in the frontend
- Inpaint via POST /v1/proxy/studio-inpaint with selected mask_rle values
- Poll GET /v2/jobs/{job_id} for result URL
Mask Formats
| Type | Data Format | Example |
|---|---|---|
| bbox | [x, y, width, height] | [120, 60, 380, 290] |
| rle | {size: [H,W], counts: [...]} | Direct output from Segmentation API |
| polygon | [[x1,y1], [x2,y2], ...] | [[100,50], [200,50], [200,150], [100,150]] |
Quick Example
# Remove an object using a bounding box
curl -X POST https://api.cn8.io/v1/proxy/studio-inpaint \
-H "X-API-Key: apk_your_key" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://s3.../photo.jpg",
"masks": [
{ "type": "bbox", "data": [120, 60, 380, 290] }
]
}'