Malabi – online image background remover, whitener and background editor Bulk background removal | Bulk Image background remover API | Malabi

Malabi Background Remover API

The most accurate bulk background removal API

This page contains the technical specifications of the Malabi Background Remover API, and is meant for developers. If the words “frontend”, “backend” or “JavaScript” mean nothing to you, you are probably in the wrong place. To simply remove the background from your images go to Malabi.

Overview

Malabi is a unique and innovative tool for removing the background from images. It was designed to provide e-commerce sellers with a fast, accurate and most importantly automatic solution to enhance their images and increase conversion rates.

Integrating the Malabi Background Remover API into your platform will allow your users to enjoy the benefits of Malabi with the click of a button.
The Malabi API works in two main phases:

  • Automatic background removal – the original image is sent to the Malabi servers, automatically enhanced and sent back to the user
  • Manual fine tuning – this is an interactive process in which the user can manipulate the result by adding hints for the Malabi algorithm to follow

The advanced algorithm behind Malabi will automatically detect the object in the image and will extract it from the background. The second phase is available in order to allow the user to help Malabi in cases where it fails to detect the object automatically.

The RESTful API uses simple http/https calls (GET, POST, PUT), so any client technology may be used. We also provide a simple editing tool, built as a JavaScript widget inside an iFrame. We encourage you to use this widget in your integration in order to avoid the complexity of building your own UI for this process.

Follow this quick and simple guide to integrate the Malabi Background Remover API into your system.

Getting Started

A typical usage will include both backend and frontend integrations:

  1. The user uploads a new image onto your website
  2. Your backend server sends a request to the Malabi Background Remover API
  3. Malabi processes the image and returns a response
  4. The result is presented to the user
  5. ​The user can touch-up the image using the client-side tool

To get your free API key and id, click the button below. You can use these credentials until you complete your integration, and purchase a paid subscription plan only when you’re ready to go.

Your API credentials:

API key :      <== keep this key secret!

API id :     

IMPORTANT: keep your API key safe and secret. This is the authentication used to access all of your images and future billings.

 

Once you have your key and id, you can start making test calls by calling the domain api.malabi.co/test instead of api.malabi.co/v1
Test is limited to 200 images per month, and images returned by test calls will include a watermark.

Backend Integration

Normally, the Malabi background removal API should receive a link to an image that is publicly available online. If however, your images are not stored online (or not publicly available), the API provides a simple way to upload your images (described below).

Start by making a POST call from your backend server to Malabi Background Remover API. This call will include your secret API key, so it is crucial that it will not be sent directly from your client side (otherwise, your secret API key will be visible to all, and others will be able to access your images and use your credits).

The call should look like the example below (see full API Calls documentation).

 

The request can be carried out synchronously or asynchronously. To make an asynchronous call pass the callback_url parameter.

In a synchronous call, an HTTP response will be returned after the image processing is done and the result image is ready.

In an asynchronous call, an HTTP response will be returned immediately but the result_image_url will only be valid after the image processing in done (a few seconds), at which point you will receive a POST call to the callback_url you have provided.

The response body (to both types of calls), as well as the callback body, will look like this (see full API Calls documentation for all possible error code and responses):

 

Once you have received a response for a synchronous call or the callback to an asynchronous call, the result_image_url will hold your result image.

The callback_url parameter should point either to a server with a public access (ready to receive POST calls from Malabi) or an AWS Simple Queue Service opened for public ‘SendMessage’. In the later case, Malabi will send a message containing the callback body to the queue.

Here are two diagrams showing the two possible types of flows.

Processing images that are not publicly available online:

The Malabi background removal API provides a simple way to upload your images in the processing call itself. Follow the instruction above, but instead of using the POST method, use the PUT method, to indicate to the API that you are uploading an image. The payload (body) of the call will be a binary representation of the image. The ‘content-type’ header should state the type of the image.

To make an asynchronous call, add a ‘callback-url’ header (note that we use a hyphen in this case). Uploading the file will be done synchronously, of course, and then the processing itself will be carried out asynchronously.

Note that using this approach, you will not be able to define the setting of the result image (shadow, background type etc.) in the processing call.

The call should look like the example below (see full API Calls documentation).

 

Frontend Integration

After an image was processed and a response was returned, you can present the result of the automatic processing to your user.
The user may wish to touch-up the result or change some settings, such as transparency or shadow. For that purpose, we have created a client side JavaScript which can be easily integrated into your website.

This script holds all of the communication with the Malabi Background Remover API and will handle all outgoing edit calls and incoming edit responses. It will append a div tag and an iframe tag to your document containing the editor along with all required controls.

You can find an example implementation of the frontend here: https://api.malabi.co/v1/toyExample.html 

Start by adding the following 3 JavaScript files to your document:

The first two will load Jquery and Materialize libraries. These are commonly used libraries, which may already be included in your code.
The third line will load Malabi.js.

Now add a simple a short script calling the malabi.init() function. This function must be called once. You cannot edit any images before it was called. A good practice will be to add it to the $(documet).ready() function (called by Jquery).

​The malabi.init() function expects a single object containing your API id (DO NOT pass your API secret key here).
Now let’s add a call to malabi.edit(). This will open a modal window containing the editor.

The function expects an image id and an image secret (taken from the response to the POST request). The image secret ensures that no one could view or change your images without your permission.
The function also takes a third parameter, a callback function to be called after the user has saved a new result. The callback function will receive an image object (like the one in the POST call response).

 

That’s it – you should now be able to run your code and see the full functionality of the Malabi background removal API.

Zero Integration Editor

Malabi also offers a Zero Integration Editing client. This option usually suits a system with no UI, but can also prove useful in case your system is closed for UI changes or you are looking for a quick and easy solution.
Note that with this option the user will be directed to an external website, which you have no control over. Each call for edit will take a bit more loading time, since the JavaScript is reloaded on each request.

Using the Zero Integration Editing client is as easy as structuring a URL with a query holding the information and passing it to your end user.

Note that the callback parameter value should be URL encoded and cannot be a URL to an AWS simple queue service. It should be a publicly available URL ready to accept a POST call holding an image data (formatted the same way as the other responses and callbacks).

Other Web Framework Support

The Malabi background removal editing client uses Materialize framework by default. If your website uses Bootstrap, it is advisable to use the editor’s Bootstrap version. to do so, add “framework”: “bootstrap” to the initialization object and change the scripts loaded by the page.

You can find an example of the frontend integration with Bootstrap here example with Bootstrap

Service Agreement​

By using the Malabi Background Remover API you accept the terms of its services agreement.
© Copyright ArtInCam Ltd. (2016). All rights reserved.

Image Requirements

Images sent to Malabi as input images must meet the following limitations

  • Image musk either be publicly accessible or located on S3 and accessible to Malabi servers
  • Supported types – jpeg (24 or 32 bit), png (24 or 32 bit)
  • Maximum image size – images larger than 4 Mega-Pixels will be resized to 4 Mega-Pixels
  • Minimum image size – 70 pixels on each dimension