v1

latestOpenAPI 3.0.02026-07-133840.6 KB
Background Removal

Remove the background of an image

Removes the background of a JPG/PNG/WebP image.

  • File size: up to 22 MB
  • Input resolution: up to 50 megapixels
  • Image source: File upload (binary or as base64 encoded string) or download from URL
  • Image Content: Any photo with a foreground (e.g. people, products, animals, cars, etc.)
  • Output resolutions available: Preview (up to 0.25 megapixels), Full (up to 25 megapixels), 50MP (up to 50 megapixels)

Requires either an API Key to be provided in the X-API-Key request header or an OAuth 2.0 access token to be provided in the Authorization request header.

post/removebg

Request body

image_file_b64string

Source image file (base64-encoded string). (If this parameter is present, the other image source parameters must be empty.)

image_urlstring

Source image URL. (If this parameter is present, the other image source parameters must be empty.)

size'preview' | 'full' | 'auto'

Maximum output image resolution:

  • "preview" (default) = Resize image to 0.25 megapixels (e.g., 625×400 pixels) – 0.25 credits per image
  • "full" = Use original image resolution, up to 25 megapixels (e.g., 6250×4000) with formats ZIP / JPG / WebP, or up to 10 megapixels (e.g., 4000×2500) with PNG – 1 credit per image
  • "50MP" = Use original image resolution, up to 50 megapixels (e.g., 8000×6250) with formats ZIP / JPG / WebP, or up to 10 megapixels (e.g., 4000×2500) with PNG – 1 credit per image
  • "auto" = Use highest available resolution, up to 25 megapixels (e.g. 6250×4000) (based on image size and available credits).

For backwards-compatibility this parameter also accepts the values "medium" (up to 1.5 megapixels) and "hd" (up to 4 megapixels) for 1 credit per image. The value "full" is also available under the name "4k" and the value "preview" is aliased as "small" and "regular".

type'auto' | 'car' | 'product' | 'person' | 'animal' | 'graphic' | 'transportation'

Detect or set a foreground type.

We recommend using type = auto to automatically detect the type of foreground.

To specify only one type of foreground, set type to one of these values:<br> car, product, person, animal, graphic, transportation.

type_levelstring

Classification level of the detected foreground type:

  • "none" = No classification (X-Type Header won't bet set on the response)
  • "1" = Use coarse classification classes: [person, product, animal, car, other]
  • "2" = Use more specific classification classes: [person, product, animal, car, car_interior, car_part, transportation, graphics, other]
  • "latest" = Always use the latest classification classes available
format'auto' | 'png' | 'jpg' | 'zip' | 'webp'

Result image format:

  • "auto" = Use PNG format if transparent regions exist, otherwise use JPG format (default),
  • "png" = PNG format with alpha transparency,
  • "webp" = WebP format with alpha transparency,
  • "jpg" = JPG format, no transparency,
  • "zip" = ZIP format, contains color image and alpha matte image, supports transparency (recommended for fastest processing).
roistring

Region of interest: Only contents of this rectangular region can be detected as foreground. Everything outside is considered background and will be removed. The rectangle is defined as two x/y coordinates in the format "x1 y1 x2 y2". The coordinates can be in absolute pixels (suffix 'px') or relative to the width/height of the image (suffix '%'). By default, the whole image is the region of interest ("0% 0% 100% 100%").

cropboolean

Whether to crop off all empty regions (default: false).<br> Note: Cropping has no effect on the amount of charged credits.

crop_marginstring

Adds a margin around the cropped subject (default: 0). Can be an absolute value (e.g. "30px") or relative to the subject size (e.g. "10%"). Can be a single value (all sides), two values (top/bottom and left/right) or four values (top, right, bottom, left). This parameter only has an effect when "crop=true". The maximum margin that can be added on each side is 50% of the subject dimensions or 500 pixels.

scalestring

Scales the subject relative to the total image size. Can be any value from "10%" to "100%", or "original" (default). Scaling the subject implies "position=center" (unless specified otherwise).

positionstring

Positions the subject within the image canvas. Can be "original" (default unless "scale" is given), "center" (default when "scale" is given) or a value from "0%" to "100%" (both horizontal and vertical) or two values (horizontal, vertical).

channels'rgba' | 'alpha'

Request either the finalized image ("rgba", default) or an alpha mask ("alpha").<br> Note: Since remove.bg also applies RGB color corrections on edges, using only the alpha mask often leads to a lower final image quality. Therefore "rgba" is recommended.

add_shadowboolean

Warning: add_shadow is deprecated and will be removed in the next major release, version 2.0. Please use shadow_type instead.<br>

Setting add_shadow = true will set the shadow_type parameter to shadow_type [car] = car. A car shadow will only be generated if the foreground type is detected or specified as car.

shadow_typestring

Generate shadows based on your foreground type. remove.bg supports four different shadow types: car, 3D, drop, none.

Use shadow_type = auto to automatically assign the most suitable shadow_type for each foreground type. See the default assignments below. Use shadow_type = $shadow_type to specify a single type of shadow for all foreground types.

Replace shadow_type = auto with shadow_type [$type] = $shadow_type to assign specific shadow types per foreground type. Unmentioned foreground type(s) will return no shadow.

Default assignments:<br> shadow_type [car] = car,<br> shadow_type [product] = drop,<br> shadow_type [person] = 3D,<br> shadow_type [animal] = drop,<br> shadow_type [transportation] = 3D,<br> shadow_type [graphic] = drop,<br> shadow_type [other] = drop

shadow_opacitystring

Set a shadow's opacity, i.e. darkness. Can be set to any value from 0 (lightest) to 100 (darkest) or auto for default values, shown below.

shadow_opacity = n (0 - 100), auto

Replace shadow_opacity = auto with shadow_opacity [$type] = $n to assign specific opacity values per foreground type. Unmentioned foreground type(s) with set shadows will fall back on default opacity assignments.

Default values:<br> shadow_opacity [car] = 90<br> shadow_opacity [product] = 50<br> shadow_opacity [person] = 50<br> shadow_opacity [animal] = 50<br> shadow_opacity[transportation] = 50<br> shadow_opacity [graphic] = 50<br> shadow_opacity [other] = 50<br>

semitransparencyboolean

Whether to have semi-transparent regions in the result (default: true).<br> Note: Semitransparency is currently only supported for car windows (this might change in the future). Other objects are returned without semitransparency, even if set to true.

bg_colorstring

Adds a solid color background. Can be a hex color code (e.g. 81d4fa, fff) or a color name (e.g. green). For semi-transparency, 4-/8-digit hex codes are also supported (e.g. 81d4fa77). (If this parameter is present, the other bg_ parameters must be empty.)

bg_image_urlstring

Adds a background image from a URL. The image is centered and resized to fill the canvas while preserving the aspect ratio, unless it already has the exact same dimensions as the foreground image. (If this parameter is present, the other bg_ parameters must be empty.)

Example request

{
  "image_url": "https://www.remove.bg/example-hd.jpg"
}

Response

Image background removed

Example response

{
  "data": {
    "result_b64": "iVBORw0KGgoAAAANSUhEUgAAAIsAAACFC...",
    "foreground_width": 100,
    "foreground_height": 100
  }
}
All 3 operations