Automatic background removal from images

We are excited to announce the addition of a new Robot to our fleet: The /image/bgremove Robot can automatically detect and remove backgrounds from images using advanced AI technology. This powerful tool allows you to create clean, professional-looking results with transparent backgrounds, saving you time and effort while producing high-quality images.
Automatic background removal is one of the most useful additions to everybody's toolbox. E-commerce retailers can create uniform product catalogs with consistent backgrounds, focused on the products themselves. Social networks benefit from clean headshots with standardized backgrounds, creating a cohesive look across team pages. Graphic designers and marketers save significant time by quickly extracting subjects from photographs without tedious manual masking work, allowing for faster creation of digital compositions, social media assets, and marketing materials. More advanced applications include virtual try-on experiences for clothing and accessories, augmented reality product placement, and virtual room planning for furniture and decor items. By automating this process, Transloadit helps businesses of all sizes achieve professional results without the time-consuming manual editing traditionally required.
Using 🤖/image/bgremove
Let's start with an example image. The following shows a portrait photograph with a background that we want to remove:

To remove the background using the /image/bgremove Robot, we can use the following Template:
{
"steps": {
":original": {
"robot": "/upload/handle"
},
"background_removed": {
"use": ":original",
"robot": "/image/bgremove",
"format": "png"
},
"export": {
"use": [":original", "background_removed"],
"robot": "/s3/store",
"credentials": "YOUR_AWS_CREDENTIALS",
"path": "my_target_folder/${unique_prefix}/${file.url_name}"
}
}
}
In this Template, we first pass the image through the
/image/bgremove Robot. The only parameter we need
to specify is format
, which is set to png
by default since we need a format that supports
transparency. The Robot will take care of the rest using advanced AI technology.
Finally, both the original image and the processed image with the background removed are passed through the /s3/store Robot to store them in an S3 bucket. Of course, you can replace this with any of our other file exporting Robots, which support Google Cloud Storage, Azure Blob Storage, and Digital Ocean Spaces, among others.
After processing our example image, we can see that the background has been completely removed, leaving only the subject with a transparent background:

Combining with other Robots
The /image/bgremove Robot works great on its own, but it becomes even more powerful when combined with other Robots. For example, you might want to resize the image or place it on a different background color after removing the original background.
Here's an example that removes the background, replacing it with a single color while resizing the image to 600x600 pixels:
{
"steps": {
":original": {
"robot": "/upload/handle"
},
"background_removed": {
"use": ":original",
"robot": "/image/bgremove",
"format": "png"
},
"resized": {
"use": "background_removed",
"robot": "/image/resize",
"width": 600,
"height": 600,
"resize_strategy": "fillcrop",
"background": "#f0f0f0"
}
}
}
Here's the result of the above Template:

Supported formats
The /image/bgremove Robot supports nearly all image formats as input, including but not limited to JPEG, PNG, GIF, TIFF, WebP, BMP and HEIF. A full list of all formats supported by our AI services can be found in the image format documentation.
The output format, on the other hand, is currently limited to PNG, as it's the most common format that supports transparency. If you need the final image in a different format, you can use the /image/resize Robot to convert it after removing the background.
Conclusion
With the /image/bgremove Robot, you can automatically remove backgrounds from images. This powerful tool leverages advanced AI technology to save you time and effort while producing professional-quality results.
For a comprehensive look at everything available to you with this Robot, including information about pricing, check out its documentation.