https://api.extractbg.com/v1.0/extractbg/
APIKEY - Your API Key.
image - The image to process. (Binary)
type - The type of foreground element to detect. You can specify object for object detection, or person for human detection. (product or person)
size - The size of the image. (NxN)
bgcolor - Adds a solid background colour to the image. Expressed in hex eg 008080. (Hex)
f - Foreground Detection Threshold. The trimap foreground threshold. (Integer)
b - Background Detection Threshold. The trimap background threshold. (Integer)
e - Erode Detection Size. The size of the element erosion. (Integer)
<?php
$url = 'https://api.extractbg.com/v1.0/extractbg/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"image" => curl_file_create("/path/to/image.jpg"),
"APIKEY" => 'YOUR_API_KEY',
"size" => '1024x1024'
));
$result = curl_exec($ch);
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}
file_save_contents("newimage.png",$result);
?>
import requests
response = requests.post('https://api.extractbg.com/v1.0/extractbg/',
files={'image': open('/path/to/image.jpg', 'rb')},
data={'APIKEY': 'YOUR_API_KEY'},
)
if response.status_code == requests.codes.ok:
with open('newimage.png', 'wb') as out:
out.write(response.content)
else:
print("Error:", response.status_code, response.text)
Response response = Request.Post("https://api.extractbg.com/v1.0/extractbg/")
.body(
MultipartEntityBuilder.create()
.addBinaryBody("image", new File("/path/to/image.jpg"))
.addTextBody("APIKEY", "YOUR_API_KEY")
.build()
).execute();
response.saveContent(new File("newimage.png"));