Get Premium!

1000 Images


  • upto 1000 images per month
  • Access to our API
  • Advanced options
  • Priority Processing
$62.99 / Month
Get 1000 Images

2400 Images


  • 2400 images per month
  • Access to our API
  • Advanced options
  • Priority Processing
$124.99 / Month
Get 2400 Images!

Why Premium?

  • Automate Workflows
  • Faster processing
  • Integrate with your own website or backend
  • Advanced Options
  • Higher Image Resolutions

Got Premium!

API

End Point

https://api.extractbg.com/v1.0/extractbg/

Required Variables

APIKEY - Your API Key.

image - The image to process. (Binary)

Optional Variables

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)

Examples

PHP

<?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); ?>

Python

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)

Java

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"));