Background Remover (BGR) API Overview
The Background Remover (BGR) API, utilizing advanced AI, enables users to remove the background on any vehicle image provided. The output of this API can serve as a valuable complement to the information provided in a car report.
To access the API for the BGR images, you must have an API-enabled account, which will provide you with an API Key. This Key allows your application to send data transfer requests to the VinAudit API servers.
Supported Methods of Image Input
- Passing Image URL: Requires a publicly accessible URL pointing to the image. This method is convenient for images already hosted online.
- Passing Image File: Allows the direct upload of image files (jpg, png) from the client’s system. This method is suitable for images stored locally on the user’s device.
- Passing Base64 Image: Involves sending the image as a Base64-encoded string. This method is beneficial for applications that process images in a format that can be easily encoded and transmitted within JSON structures.
Background Manipulation Options
- White Background: Replaces the original background with a plain white background.
- Transparent Background: Makes the original background transparent.
- Custom Background: Allows the user to upload a custom background image that replaces the original background. For operations requiring a custom background, the user must pass a publicly accessible URL or upload a file for the custom background.
- Generative Background: This will generate a background for the image based on the prompt provided. (Check “Generative Background” section for sample result). This option doesn’t support layout and effect. So with this background set layout and effect to none.
Note: Output will also include ‘window correction,’ which will remove any objects in the background that appear through a window, such as a building, trees, other vehicles, etc.
The original vehicle image provided by the user before any background manipulation.
Optionally replaces the vehicle’s license plate with a custom or blank plate for privacy or branding purposes.
Replaces the original image background with a clean white background—ideal for listings and reports.
Allows users to upload or link a custom background image to replace the original one.
Automatically generates a realistic background based on a text prompt, powered by AI.
https://images.vinaudit.com/v2/remove-background
|
|---|
| Parameter | Description | Required | Example |
|---|---|---|---|
| key | Your VinAudit API key | Yes | YOUR_API_KEY |
| image_url | Publicly accessible URL of the source image in .jpg, .png, or .webp format. Provide one of image_url, image_base64, or image_file. |
One of 3 | https://images.vinaudit.com/samples/image1.jpg |
| image_base64 | Base64 encoded source image. Provide one of image_url, image_base64, or image_file. |
One of 3 | iVBORw0KGgoAAA… |
| image_file | Image file upload via multipart form. Provide one of image_url, image_base64, or image_file. |
One of 3 | files={‘image_file’: open(‘/path/to/image.jpg’,’rb’)} |
| background | Background mode:
|
(optional) | white_background |
| background_url | Public URL for custom background image. If both background_url and background_file are sent, background_url takes priority. |
(optional) | https://images.vinaudit.com/samples/background1.jpg |
| background_file | Custom background file via multipart form upload. Use if not providing background_url. |
(optional) | files={‘background_file’: open(‘/path/to/bg.jpg’,’rb’)} |
| layout | Output layout: center, crop, or none. Default is none. With generative_background, must be none. |
(optional) | center |
| effect | Shadow effect: shadow or none. Default is shadow. With generative_background, must be none. |
(optional) | shadow |
| background_prompt | Text prompt to guide generative_background. Ignored for other background modes. | (optional) | a studio image of car inside room |
| background_negative_prompt | Words to avoid for generative_background. Ignored for other modes. | (optional) | blur, low quality |
| plate_replacement | Replace plate overlay, image to enable, none to disable. Default is none. | (optional) | image |
| plate_base64 | Base64 of the replacement plate image, required if plate_replacement=image. | (optional) | VBORw0KGgoAAA… |
Response Elements
| Element | Description | Example |
|---|---|---|
| output_url | Direct URL of processed image. | http://bg2.imgset.info/i2/72ab067a351ae9a3a14e49caa6cbfdf0d77.jpg |
| error | One of: invalid_input, unauthorized_request, no_data, request_failed, or (blank) if no error | (blank) |
| error_description | A human-readable message providing additional context about the error. The message format and wording may vary as new error cases are introduced, and should not be relied on for programmatic handling. | (blank) |
Python Code Snippets For Sending API Request
https://images.vinaudit.com/v2/remove-background?image_url=https://images.vinaudit.com/samples/image1.jpg&key=YOUR_API_KEY&background=white_background&effect=shadow&layout=center&plate_replacement=nonePOST Request via Image URL
import requests
import json
url="https://images.vinaudit.com/samples/image2.jpg"
req_json={
"image_url": url, ##URL Must be publically accessible
"key": "YOUR_API_KEY", ##KEY to access API
'background':"white_background", ##It can take "white_background", "custom_background", "transparent_background" or "generative_background"
'layout': "center", ##Whether to center/crop the output image
'effect': "shadow", ##Whether to have a shadow in the resulting image or not
}
api_url='http://images.vinaudit.com/v2/remove-background'
response=requests.post(api_url,data=req_json)
print(response.content)
POST Request via Image File Base64 Encoded String
import requests
import json
import base64
file_name = 'image1.jpg' ##Assuming your local file name is test.jpg
with open(file_name, 'rb') as file:
encoded_string = base64.b64encode(file.read())
req_json = {
"image_base64": encoded_string, ###This is base64 Encoded string of source image
"key": "YOUR_API_KEY", ##KEY to access API
'background': "white_background", ##It can take "white_background", "custom_background" "transparent_background" or "generative_background"
'layout': "center", ##Whether to center/crop the output image
'effect': "shadow", ##Whether to have a shadow in the resulting image or not
}
api_url='http://images.vinaudit.com/v2/remove-background'
response = requests.post(api_url, data=req_json)
print(response.text)
POST Request via Image File
import requests
import json
req_json={
"key": "YOUR_API_KEY", ##KEY to access API
'background':"white_background" , ##It can take "white_background", "custom_background", "transparent_background" or "generative_background"
'background_url':'',
'layout': "center", ##Whether to center/crop the output image
'effect': "shadow", ##Whether to have a shadow in the resulting image or not
}
files = {'image_file':open('/PATH/TO/image1.jpg', 'rb')} ##Assuming your local file name is test.jpg
api_url='http://images.vinaudit.com/v2/remove-background'
response=requests.post(api_url,data=req_json,files=files)
print(response.content)
Use generative background & Replace License Plate
import requests
import json
file_name='vinaudit-logo-small-white.png'
with open(file_name,'rb') as file:
license_plate_encoded_string = base64.b64encode(file.read())
url="https://images.vinaudit.com/samples/image3.jpg"
req_json={
"image_url": url, ##URL Must be publically accessible
"key": "YOUR_API_KEY", ##KEY to access API
'background':"generative_background", ##It can take "white_background", "custom_background" & "transparent_background" or "generative_background"
'background_prompt': "a studio image of car inside room",
'background_negative_prompt': "blurr, low quality",
'layout': "none", ##With generative_background this can only take none
'effect': "none", ##With generative_background this can only take none
'replace_license_plate': "1",
'license_plate_input': license_plate_encoded_string
}
api_url='http://images.vinaudit.com/v2/remove-background'
response=requests.post(api_url,data=req_json)
print(response.content)
Provide a Custom Background using URL
import requests
import json
url="https://images.vinaudit.com/samples/image3.jpg"
req_json={
"image_url": url, ##URL Must be publically accessible
"key": "YOUR_API_KEY", ##KEY to access API
'background':"custom_background", ##It can take "white_background", "custom_background" & "transparent_background" or "generative_background"
'background_url':'https://images.vinaudit.com/samples/background1.jpg', ##URL of custom background
'layout': "center", ##Whether to center/crop the output image
'effect': "shadow", ##Whether to have a shadow in the resulting image or not
}
api_url='http://images.vinaudit.com/v2/remove-background'
response=requests.post(api_url,data=req_json)
print(response.content)
Provide a Custom Background using local file
import requests
import json
import base64
req_json={
"key": "YOUR_API_KEY", ##KEY to access API
'background':"custom_background", ##It can take "white_background", "custom_background", "transparent_background" or "generative_background"
'layout': "center", ##Whether to center/crop the output image
'effect': "shadow", ##Whether to have a shadow in the resulting image or not
}
files = {
'image_file':open('/home/PATH/TO/LOCAL/FILE/image1.jpg', 'rb'),
'custom_background': open('/home/PATH/TO/LOCAL/FILE/background1.jpg', 'rb')
}
api_url='http://images.vinaudit.com/v2/remove-background'
response=requests.post(api_url,files=files,data=req_json)
print(response.content)
The most comprehensive Automotive Data & Analytics
- Automotive Market Trends & Insights
- Research & White Papers
- Auto Market Analytics Articles
- VIN Decoder & Lookup
