Brush edits and masks
mode: "brush" changes only the area you mark. Everything outside it stays exactly as it was. Describe the change in prompt, or pass preset: "remove" to take away what is marked.
There are two ways to mark the area: brush strokes in JSON, or a mask image you upload.
A mask image
Section titled “A mask image”Upload a PNG the same shape as the photo (any size: it is scaled to fit) and pass its id as maskAssetId.
- On a mask with transparency, transparent pixels mark the area to change. This is the same convention as OpenAI’s
images.edit, so masks you already make for it work here. - On a mask without transparency, white pixels mark the area to change and black pixels are kept.
const photo = await client.uploads.create('./kitchen.jpg');const mask = await client.uploads.create('./kitchen-island-mask.png');
const design = await client.designs.createAndWait({ mode: 'brush', inputAssetId: photo.id, maskAssetId: mask.id, prompt: 'A white marble island with brass stools',});photo = client.uploads.create("kitchen.jpg")mask = client.uploads.create("kitchen-island-mask.png")
design = client.designs.create_and_wait( mode="brush", input_asset_id=photo["id"], mask_asset_id=mask["id"], prompt="A white marble island with brass stools",)curl -X POST https://api.remodeled.ai/public/v1/designs \ -H "Authorization: Bearer $REMODELED_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mode": "brush", "inputAssetId": "01a1ebfd-494e-752c-86b5-d58f61313030", "maskAssetId": "01a1ebfd-4972-7c11-9b3a-1e6a2f0c4d55", "prompt": "A white marble island with brass stools" }'Brush strokes
Section titled “Brush strokes”If your product has its own brush tool, send the strokes as they were drawn. Points are [x, y] pairs from 0 to 1 across the photo, so they do not depend on the photo’s pixel size. size is the brush diameter as a fraction of the photo’s shorter side (0.01 to 0.3). An erase stroke takes paint away again.
{ "mode": "brush", "inputAssetId": "01a1ebfd-494e-752c-86b5-d58f61313030", "preset": "remove", "mask": { "strokes": [ { "points": [[0.42, 0.61], [0.47, 0.63], [0.55, 0.64]], "size": 0.08, "mode": "paint" } ] }}Good masks
Section titled “Good masks”- Cover the whole object plus a small margin. A tight outline leaves a halo of the old object.
- The marked area must be between about 0.5% and 90% of the photo, or the API answers
422 invalid_mask. - To place a product of your own, upload its photo and pass it in
itemAssetIdswith a prompt such as “Put this armchair in the marked corner”.