Background removal and generation
Last updated
Last updated
Background of the image can be removed with "remove" parameter of background options.
Also removed background can be replaced with generated one.
Description of "type" parameter of remove background function.
Parameter | Description |
---|---|
Let's check some examples.
Click on the result image to see the difference.
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.
Generating background is fantastic way of improving product photo look. It can be even solution for creating product pack shots without need of manually taking expensive commercial photo shoots.
Let's check what we can do.
Without sample_num:
We can specify also image resolution:
When specifying a color:
Parameter | Description |
---|---|
description
Text prompt describing the scene
item_area_percentage
Parameter between 0 and 1 that controls size of the object which is placed in the middle of final image. So, 0.85 is 85%
sample_num
Seed for random generator. Basically is "id" of generated image. When not specified, image will randomly different every time.
color
When color is specified, generated background is converted to b&w and then to specified color. It works best for prompts such as: "item standing on plain white background". Color has to be RGB array - f.e. [255,255,255]
remove
Parameter that controls background removal algorithm.
"auto" - (default) automatically picks remove background type based on image
"v2" - new remove background algorithm
"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