API Integration

Remove the background of any image
curl -F 'api_key=YOUR_CLICKMAJIC_API_KEY' -F 'sourceFile=@source_image_path' -f https://api.clickmajic.com/v1/remove-background -o output.png
Get API Key

Our AI will remove the background from any image that has a clear foreground and Background. (Tested with human, cars, animals, & products )

Check out our sample code

Remove background from image file

Environment

  • Curl
  • PHP
  • Java
  • Kotlin
  • .NET
  • Phyton
  • Swift
  • Node

Output Formats

Easily request any one of the 2 formats via our format parameter

Format Resolution
PNG Upto 10 MP , Ex - 3872 x 2592
JPG Upto 16 MP , Ex - 6250 x 4000
*Please note that PNG images above 10 megapixels are not supported by default. If you don't require transparency we recommend using the JPG format.

API Reference

Server URL:https://api.clickmajic.com/v1
Method:POST
API endpoint:/remove-background
Request Body:multipart/form-data
Parameters
api_key string Your API key
sourceFile string($binary)

Source image file. Support only PNG, JPG, JPEG.

*** use only one source parameter at a time
sourceUrl string

Source image url. Support only PNG, JPG, JPEG.

*** use only one source parameter at a time
sourceBase64 string

Source image base64 format. Support only PNG, JPG, JPEG.

*** use only one source parameter at a time
bgImageFile string($binary)

This binary image file will be placed as a background of the output binary image. This image will be resized according to the output image aspect ratio. supported bgImageFile formats are 'png', 'jpg', 'jpeg'.

*** use only one bg parameter
bgImageUrl string

This image from the url will be placed as a background of the output binary image. This image will be resized according to the output image aspect ratio. supported bgImageUrl formats are 'png', 'jpg', 'jpeg'.

*** use only one bg parameter
bgImageBase64 string

This image from the base64 string will be placed as a background of the output binary image. This image will be resized according to the output image aspect ratio. supported bgImageBase64 formats are 'png', 'jpg', 'jpeg'.

*** use only one bg parameter
bgColorCode string

Output with solid background color. Has to be HEX color code. (e.g. #72E4B3, #B3D472).

*** Please Note: Add '#' before color code. *** use only one bg parameter
format string

Output image format. Default value 'png'. Otherwise 'jpg' for JPG format and 'png' for PNG format. 'png' format support alpha transparency.

crop boolean

Default value: false. It will crop all extra transparent pixels

cropMargin string

This parameter only work when crop applied (crop=True). Default value of this parameter is 0px. it supports input value in the following ways


Ex. 20px - create margin all around the subject..
Ex. 12% - create margin all around the subject with respect to the subject size..
Ex. 10px,20px - create 10px margin left and right side, 20px margin top and bottom side..
Ex. 10%,20% - create 10% margin left and right side, 20% margin top and bottom side with respect to the subject size..
Ex. 10px,20px,18px,24px - create 10px margin left, 20px margin top, 18px margin right and 24px margin in bottom..
Ex. 10%,20%,18%, 24% - create 10% margin left, 20% margin top, 18% margin right and 24% margin in bottom with respect to the subject size..
crop_margin parameter support max 500px or max 50% of the subject size.

scale string

This parameter scales the subject in the output image. Can be any range between 10% or 100% depending on the image dimensions. Default position parameter value is 'center', unless any other position parameter value is given.

position string

This parameter place the subject within the image canvas. Only works when 'scale' parameter is given. Default value is 'center'. Can be a single value between 0% to 100%(horizontal and vertical) or two values between 0% to 100% separated by comma(eg: 10%,18%) both horizontal and vertical.

preview boolean

Default value: false. If true it will resize image to 0.25 megapixel. (eg value: 400x600 pixels)

channel string

This parameter will return the image channel(red, green, blue, alpha) in RGBA or alpha mask format. 'rgba' is the default parameter, returns alpha mask when value is set to 'alpha'.

roi string

This parameter when given will let you extract the region of interest of a particular image, only the contents of the selected rectangular will be consider as a foreground and everything else will be consider as background and will be completely removed.
ex. 200px,320px,400px,230px - top-left,bottom-right coordinates.
ex. 10%,15%,25%,30% - top-left,bottom-right with respect to the image size.

Response
Code : 200

Successfully removed image background

Binary image data
Code : 401

Error: api_key missing or invalid api_key (No credit deducted)


Example :

{
  "errors": [
     {
      "detail": "Unauthorized.",
      "status": 401
     }
   ]
}
Code: 422

Error: No credits remaining, or invalid parameters, or unable to process input image, or Api rate limit crossed
(No credit deducted)


Example :

{
  "errors": [
    {
      "status": 422,
      "detail": "No credits remaining."
    }
  ]
}

Credit API Reference

Server URL:https://api.clickmajic.com/v1
Method:GET
API endpoint:/account
Parameters
api_key string Your API key
Response
Code : 200

Successfully fetched credit details

{
  "data": {
    "creditSubscription": 123,
    "creditOneTimePayment": 123,
    "creditFree": 123,
    "creditTotal": 123
  }
}

API Rate Limit

You can instantly process upto 500 images per hour via the API, but depending on the input image megapixel resolution.

Input Image Megapixels Rate Limit approx
625 x 400 1 MP 500 images per minute
1200 x 800 1 MP 500 images per minute
1600 x 1200 2 MP 250 images per minute
2500 x 1600 4 MP 125 images per minute
4000 x 2500 10 MP 50 images per minute
6250 x 4000 16 MP 20 images per minute
Error code 422 will return if api rate limit exceed & no credit will be charged. Higher api rate limit are available for enterprise customers. Contact Us