Edit One Region with a Mask
To change one part of an image, send the image with a mask. Mask colors differ between endpoints, so check this table before you build one:
This page covers Precise Edit and Inpaint.
Choose an endpoint
Build the mask
- Make the mask the same width and height as the image.
- Paint the area to change black and everything else white. Precise Edit rounds in-between values to the nearer of the two and needs both colors in the mask.
- Save it as JPEG, PNG or WebP.
This Pillow example marks a rectangle for editing:
Send the request
Masks go in a multipart/form-data request:
Name only what should change in the prompt. By default (context_window: auto), Precise Edit fits its working region around the masked area.
The same request in Python, saving the result as edited.png:
Check the area outside the mask
Pixels outside the mask can still change slightly. Compare that area with the original before you use the result. If those pixels must stay exactly as they were, paste them back from the original:
Precise Edit returns the image at its own width and height, so its result composites as it is. Inpaint returns the nearest supported Ideogram 3.0 resolution, which the example resizes back to the original first.
In the app
The Ideogram app has the same masks in its Precise Edit app. See Masks and Inpainting.