Background processing

Background of the image can be removed with "remove" parameter of background options.
"background": {
"remove": "auto",
"color": "#FFFFFF"
}
Description of "type" parameter of remove background function.
Parameter
Description
remove
Parameter that controls background removal algorithm.
  • "auto" - (default) automatically picks remove background type based on image
  • "human" - background removal optimized for photos of people
  • "item" - background removal optimized for photos of items
color
Parameter that controls image background.
If given, image alpha channel will be composited with it.
  • auto - API first tries to identify frame around the object (like in typical ecommerce product photos) and uses that color. The fallback is white color.
  • "#FFFFFF" - RGB color in hexadecimal format.
  • "transparent" - background will be empty for image formats that allows that, f.e. PNG or WEBP.
replace
URL for the background image replacement
Let's check some examples.
Click on the result image to see the difference.
transparent
white
replace
"remove_background": {
"type": "auto",
"background": "transparent"
}
"remove_background": {
"type": "item",
"background": "#FFFFFF"
}
{
"url": "https://deep-image.ai/api-example.png",
"background": {
"remove": "auto",
"replace": "https://images.pexels.com/photos/628281/pexels-photo-628281.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"
}
}

Item cropping

Let's combine background removal, padding and cropping. With those combinations we are able to put object with any proportions in a desired canvas frame at the center with distance specified as padding option.
{
"url": "https://deep-image.ai/api-example2.jpg",
"width": 1000,
"height": 1000,
"fit": {
"crop": "item"
},
"background": {
"remove": "auto",
"color": "#FFFFFF"
},
"padding": 100
}
Result