Malabi – online image background remover, whitener and background editor Bulk background removal | Bulk Image background remover API | Malabi
Remove Background from Image Online, for free Malabi Favicon

Malabi Background Remover 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

To get you up and running, you will need an API key and API id. Contact our support team at info@malabi.co and request an API key and id.

The API key is a 40 characters string and should look like this: Z7ZdWDHrVi5IExGGFr7z28qGNDdtZpDG8AcawOzj

The API id is a 10 characters string and should look like this: k0146ax0gd

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

 

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

Backend Integration

After the image was uploaded, make 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 you 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.

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).

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