
Background Removal
Automatically and quickly remove image background with high accuracy
About
Background Removal API offers advanced image analysis for foreground segmentation and effortless background removal. It integrates seamlessly into your systems with just a few lines of code.
Remove Background
Our AI-driven algorithms swiftly detect and accurately separate foreground edges from the background. Subsequently, they meticulously remove the background, ensuring the pictures are cut without visible artifacts.
Change Background
After processing, our advanced solution can effortlessly and quickly return an image with a transparent background or seamlessly replace the background with any specific picture provided by the user.
Automate Processes
It enhances image processing efficiency and delivers outstanding results effortlessly by seamlessly integrating the automatic background removal solution into your applications, websites, software, or company workflows.
Demo
Try this solution out right now! Select one of the pictures below or upload your own image.





Bubble.io plugin integration
Step-by-step guide
Step 1: Install the plugin via the “Plugins” section in the development portal of your application.
Step 2: To add the “Remove background” action to your Bubble workflow, simply navigate to the “Plugins” section in the workflow editor and select the desired item from the list.
Step 3: Set the image source. You can choose to set a static image if you prefer, but it is more common to set a dynamic image source.
Example: The typical case is to use PictureUploader’s or FileUploader’s value as the source for a “Dynamic image”.
Step 4 (optional): Enable "Mask mode" to receive the foreground object mask. If it better suits your needs, switch the result representation from base64 to a URL.
For more details, see below ↓
Step 5: Retrieve and use the returned values.
Example: Use the “Result image” to update a HTML element through a Custom state.
For more details, see below ↓
About “base64” and “URL“
Base64 is a common method for encoding a binary file as a string. It can be used for base64 file encoding in various applications, including web applications. By default, the Background Removal API returns a PNG image encoded as a base64 string. However, in some cases, it may be more appropriate to obtain a direct URL to an image file. API4AI also offers this functionality and hosts the resulting image for one day:
To receive the result image as a base64 string, select the "Return base64" option.
To obtain the result image as a regular URL to a file (hosted by API4AI for one day), deselect the "Return base64" option.
Hint: If you wish to set a base64 encoded image as the src attribute value of an <img> HTML element, remember to add data:image/png;base64, (don’t miss the comma!) before the actual base64 content. This informs the web browser that the src contains a PNG image encoded as base64 rather than a URL. For more information on displaying base64 images in HTML, visit: https://www.w3docs.com/snippets/html/how-to-display-base64-images-in-html.html
base64 encoded image
URL to image
About “Mask mode”
By default, the Background Removal API returns a PNG image with the background removed. However, in some use cases, it is preferred to receive a mask of the foreground object. Technically, the mask is also a PNG image, but instead of containing the original image content with the background removed, it consists of pixels ranging from black to white. White pixels correspond to the foreground area, while black pixels correspond to the background area. Grayscale pixels are transitional.
Image with the background removed
Mask of the foreground
Returned values
The “Remove background” action returns a set of values which can be used to obtain processing results or to handle errors:
result (image) – The resulting PNG image, represented as base64 string or a URL to a file hosted by api4ai (valid for 1 day).
success (yes/no) – A boolean flag indicating whether the processing finished successfully.
message (text) – A message explaining the processing status.
Looking for direct HTTP API integration?
$
curl -X "POST" \ "https://demo.api4ai.cloud/img-bg-removal/v1/general/results" \ -F "url=https://storage.googleapis.com/api4ai-static/samples/img-bg-removal-3.jpg"