Aidge Resource
Try for freeWorkplace
  • LATEST ADVANCEMENTS
    • Introducing Marco-MT: Bringing Translation to the Next Level with LLM
  • GETTING STARTED
    • Quick Start
    • Account and Authentication
    • Your First API Request
    • Test Your API Requests
    • Service Level Agreement
    • FAQ
  • API REFERENCE
    • E-commerce Information Translation
      • Marco Translator
        • Marco Translator API Reference
      • Image Translation
        • Image Translation Pro Version API Reference
        • Image Translation Pro Version Result API Call Description
        • Image Translation Standard Version API Reference
    • E-commerce Image Editing
      • Image Background Removal
        • Image Background Removal API Reference
      • Image Upscaling
        • Image Upscaling API Reference
      • Image Cropping
        • Image Cropping API Reference
      • Image Elements Removal
        • Image Elements Removal API Reference
      • Image Elements Detection
        • Image Elements Detection API Reference
    • E-commerce Virtual Model
      • Virtual Model Alternation
        • Virtual Model Alternation Submit API Reference
        • Virtual Model Alternation Result Query API Reference
      • Virtual TryOn
        • Virtual Try-on Submit API Reference
        • Virtual Try-On Query API Reference
        • General Model Library Reference
      • Hands&Feet Repair
        • Hands&Feet Repair Submit API Reference
        • Hands&Feet Repair Query API Reference
    • Editor Documentation
      • AI Model Editor
      • AI Image Editor
        • Image Workbench
        • Background Removal
        • Elements Removal
        • Image Translation
Powered by GitBook
On this page
  • Image Background Removal
  • Request Parameters
  • Sample Request
  • Response Parameters
  • Sample Response

Was this helpful?

  1. API REFERENCE
  2. E-commerce Image Editing
  3. Image Background Removal

Image Background Removal API Reference

PreviousImage Background RemovalNextImage Upscaling

Last updated 2 months ago

Was this helpful?

Image Background Removal

GET/POST /ai/image/cut/out

The Image Background Removal automatically identifies the main object in an image, separates it from the background, and returns the image of main object with white or transparent backgrounds. It provides a variety of background options and custom size selections to optimize product display.

Request Parameters

Parameter
Type
Required
Description

imageUrl

String

No

The image URL.

Either imageUrl or imageBase64 should be input as request parameter. ImageBase64 is preferred when both imageUrl and imageBase64 exist.

Input image size should be between 100×100 pixels(minimum) and 3000×3000 pixels(maximum).

imageBase64

String

No

The Base64 encoding of the image.

Either imageUrl or imageBase64 should be input as request parameter. ImageBase64 is preferred when both imageUrl and imageBase64 exist.

Input image size should be between 100×100 pixels(minimum) and 3000×3000 pixels(maximum).

backGroundType

String

Yes

The result of image background format.

Range:

WHITE_BACKGROUND:ouput white background

TRANSPARENT:output transparent background

Sample: WHITE_BACKGROUND

targetWidth

Int

No

Set the width of the output image. After setting, it returns an image with automatically cropped edge blank areas and scaled to the target size. If not, it will output original width without changing the subject's position.

Pixel Range:100-3000

Sample: 800

targetHeight

Int

No

Set the height of the output image. After setting, it returns an image with automatically cropped edge blank areas and scaled to the target size. If not, it will output original height without changing the subject's position.

Pixel Range:100-3000

Sample: 800

Sample Request

IopClient client = new IopClientImp(url, appkey, appSecret);
IopRequest request = new IopRequest();
// Adding this trial tag in header means using the trial resource to test, 
// request.addHeaderParameter("x-iop-trial","true")
request.setApiName("/ai/image/cut/out");
request.addApiParameter("backGroundType", "WHITE_BACKGROUND");
request.addApiParameter("imageBase64", "");
request.addApiParameter("targetHeight", "1000");
request.addApiParameter("imageUrl", "https://ae01.alicdn.com/kf/Sa78257f1d9a34dad8ee494178db12ec8l.jpg");
request.addApiParameter("targetWidth", "800");
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);

We provide http based sample codes in the git code repository.

Response Parameters

Parameter
Type
Description

resCode

Number

The returned result code, where 200 indicates success. For detailed error codes, please refer to the error code list.

data

Object

The returned result data.

requestId

String

A unique request ID used for troubleshooting.

success

Boolean

The status of the returned request, indicating whether the request was successful.

resMessage

String

The returned request information.

Sample Response

{
  "data": {
    "score": 0.8799999952316284,
    "imageUrl": "http://nhci-image.oss-ap-southeast-1.aliyuncs.com/data%2Fgeneral_matting_online%2FAIDC_AIB_SERVICE%2F7089bce4c9d1469cb552dd225e28a254_202406261430_0.8799999952316284.jpg?OSSAccessKeyId=LTAI5t7WDuqmGKhsCAdMMfuH&Expires=2719383457&Signature=3z8ybSgwj5Tns3LahE%2FJXPh99Tg%3D",
    "usage": 1,
    "width": 800,
    "class": "com.aidc.service.api.client.image.dto.ImageGenResponse",
    "height": 1000
  },
  "requestId": "2101364217193834573077250e647d",
  "success": true,
  "resCode": 200,
  "resMessage": "success",
  "code": "0",
  "request_id": "21015e2217193834573111639",
  "_trace_id_": "2101364217193834573077250e647d"
}

Errors

Error Code
Error Message
Description

500

system error

System error.

501

rate limit exceed

The current interface has reached the current limit. Please contact us via navigation bar or email us (aidge_support@service.alibaba.com) to increase the current limit value.

700

invalid input

The format of the input parameters does not meet the requirements, and resMessage will return detailed fields that do not meet the requirements.

801

model failed

Internal call exception, please contact us via navigation bar or email us (aidge_support@service.alibaba.com) for troubleshooting.

1000

content has sensitive data, please try other input

Content has sensitive data and cannot be handled now. Please try other input.

1001

content control failed, please retry

Content risk failed, please try other input. If an error persists,please contact us via navigation bar or email us (aidge_support@service.alibaba.com) for troubleshooting.

1002

content risk filter failed, please contact us

Content risk filter failed, please contact us via navigation bar or email us (aidge_support@service.alibaba.com) for troubleshooting.

https://github.com/Aidge-AI