Skip to content

Remove Background

PRICING DEMO

This page describes API for removing background for images. The service is great for removing background from product photos as well as photos of generic items and people. The API follows the general rules of Ximilar API as described in Section First steps.

This service API has two endpoints running at URLs:

https://api.ximilar.com/removebg/precise/removebg
https://api.ximilar.com/removebg/fast/removebg

In beta ...

  • This service is right now in beta stage. Please contact us at tech@ximilar.com to unlock it for you.

RemoveBG endpoint: /precise/removebg and /fast/removebg

Given a list of image records, this method remove backgrounds for each of them. The result images with removed background are stored temporarily for 24 in _output_url_mask and _output_url fields of json records. You can download them and use it for your use case.

Parameters:

  • records: list of photos to upscale for
    • must contain either of _url or _base64 field - see section image data for details

$ curl https://api.ximilar.com/removebg/precise/removebg -H "Content-Type: application/json" -H "Authorization: Token __API_TOKEN__" -d '{
    "records": [
        { "_url": "https://bit.ly/2IymQJv" }
    ]
}'

Returns:

  • HTTP error code 2XX, if the method was OK and other HTTP error code, if the method failed.
  • Body of the response is a JSON object (map) with the following fields:
    • status - a JSON map with a status of the method processing. It contains these subfields:
      • code - a numeric code of the operation status; it follows the concept of HTTP status codes (2XX, 4XX). Specific codes are described for each type of answer (or operation) (see below).
      • text - a text describing the status code
      • error_description - in case of the processing ended with error (codes 4XX), this field contains a detailed description of the error; this might include Java stack traces.
    • Example of statuses that can be returned:
      "status": {"code": 200, "text": "OK"}
      "status": {"code": 402, "text": "aborted by error", error_description="..."}
      "status": {"code": 500, "text": "unknown error", "error_description": "..."}
    • statistics - a map of various statistics about the processing. The only statistic included every time is
      • processing time - time of actual processing of the query [in seconds]
    • records - JSON array with the input records, each record enriched by field _output_url_mask and _output_url with url path to the masks of the foreground object. The images are available for download for 24 hours.
CLICK TO SHOW JSON RESULT

{
  "records": [
    {
      "_status": {
        "code": 200,
        "text": "OK",
        "request_id": "62e777b4-d7ad-458c-8de7-08fb173cfa2e"
      },
      "_id": "60802523-4cbe-48ca-8597-b0f79829ddfb",
      "_width": 1380,
      "_height": 868,
      "_output_url": "https://s3-eu-west-1.amazonaws.com/ximilar-tmp-images/removebg/ed2a8722-fdab-48a1-a31a-5dff97a2f48e.png",
      "_output_url_mask": "https://s3-eu-west-1.amazonaws.com/ximilar-tmp-images/removebg/356e19e2-79ee-4e7e-8db8-be5c867f4056.jpg"
    }
  ],
  "status": {
    "code": 200,
    "text": "OK",
    "request_id": "62e777b4-d7ad-458c-8de7-08fb173cfa2e",
    "proc_id": "43b577c7-d392-4bc8-b1cf-cae92b196691"
  },
  "statistics": {
    "processing time": 1.4223403930664062
  }
}