- Eraser
Description
The Eraser Route enables the removal of elements or specific areas from a given image.
You can define the area to be removed by providing a mask that outlines the region to be erased. There are two main ways recommended to generate these masks:
Masks can be created by allowing users to draw directly on the image with a brush, for example. To access the SDK that demonstrates how to implement a brush feature in your interface, please refer to the following link.
By using the
/objects/mask_generatorroute, which will generate all the possible masks for an image.
Output Characteristics
- The modified image is returned at the original resolution, preserving full visual quality without any automatic resizing or downscaling.
- All areas outside the provided mask remain completely unchanged, ensuring pixel-perfect preservation of unedited regions.
The source image to be handled by the API.
Supported input types:
- Base64-encoded string
- URL pointing to an image file that is publicly accessible and available at the time of processing.
Accepted formats: JPEG, JPG, PNG, WEBP.
The binary mask image that defines the region where object generation will occur.
Mask Requirements
- The region to generate content must have a pixel value of 255 (white).
- All other areas must have a pixel value of 0 (black).
- The mask must have the same aspect ratio as the input image.
Supported Input Types
- Base64-encoded string – provide the mask data directly in the request.
- URL – provide a publicly accessible URL to the mask image.
Accepted formats: JPEG, JPG, PNG, WEBP.
Ensure that any provided URL is publicly accessible at the time of the request.
Specifies how the input mask was created.
manual(default) – Use when the mask was generated by a user, for example, using a brush tool.automatic– Use when the mask was generated by an algorithm, such as SAM or other automated segmentation methods.
Controls whether the alpha channel values from the input image are retained in the output, if the input includes an alpha channel.
- When true: The output image maintains the original transparency of fully and partially transparent pixels.
- When false: The output image is fully opaque.
- Has no effect if the input image does not include an alpha channel.
Specifies the response mode.
- When
false(default), the request is processed asynchronously: the API immediately returns a status URL to track progress. - When
true, the request is processed synchronously: the API hold the connection open until the proccess is complete and then returns the final image URL in the response.
Optional URL for receiving the result via webhook when the async job completes. See Webhooks.
When enabled, applies content moderation to input visual.
Expected behavior:
- Processing stops if the image fails moderation.
- Returns a 422 error with details about which parameter failed.
curl -i -X POST \
https://engine.prod.bria-api.com/v2/image/edit/erase \
-H 'Content-Type: application/json' \
-H 'api_token: string' \
-d '{
"image": "https://labs-assets.bria.ai/sandbox-example-inputs/eraser_image_example.jpg",
"mask": "https://labs-assets.bria.ai/sandbox-example-inputs/eraser_mask_example.jpg"
}'{ "result": { "image_url": "string" }, "request_id": "string" }