Image Elements Removal API Reference

Image Elements Removal

GET/POST /ai/image/removal

Image Elements Removal is tailored for e-commerce images, capable of automatically identifying and removing Semi-Transparent Elements, Specific Name, Character, Color-Blocks with Characters from e-commerce images. It allows for the specification of objects to be removed within the images, achieving efficient and precise processing of large volumes of images, thus simplifying the image editing process.

Request Parameters

ParameterTypeRequiredDescription

image_url

String

No

URL of the original image; cannot be empty at the same time as Base64. It is recommended to upload the image URL, and it will be prioritized if provided. The image should be in JPG, JPEG, PNG, or BMP format, with a resolution between 512x512 and 3000x3000 pixels, and a file size of no more than 10MB.

Example: http://example.jpg/

image_Base64

String

No

Base64 of the original image (The image should be in JPG, JPEG, PNG, or BMP format, with a resolution between 512x512 and 3000x3000 pixels, and a file size of no more than 10MB.). Example: iVBORw0KGgoAAAANSUhEUgAAAAUAAA...

object_remove_elements

Number[]

Yes

Elements to be removed from the image's main subject (1=Semi-Transparent Elements; 2=Specific Name; 3=Character; 4=Color-Blocks with Characters). The main subject of the image refers to the core product area within the image. For more examples, refer to the product introduction document:Image Elements Removal.

Example: [1, 2, 4]

non_object_remove_elements

Number[]

No

Elements to be removed from non-main subjects of the image (1=Semi-Transparent Elements; 2=Specific Name; 3=Character; 4=Color-Blocks with Characters). Cannot be empty at the same time as remove_non_product_area_elements. For more examples, refer to the product introduction document: Image Elements Removal.

Example: [1, 2, 4]

mask

String

No

The specific area for removal. It is optional and requires use with an editor. The input format is RLE. If provided, it will take precedence over the remove_non_product_area_elements and remove_product_area_elements parameters.

Example: 474556 160 475356 160 476156 160 476956 160 477756 160 478556 160 479356 160 480156 160 480956 160 481756 160 482556 160 483356 160 484156 160 484956 160 485756 160 486556 160 487356 160 488156 160 488956 160 489756 160 490556 160 491356 160 492156 160

Sample Request

IopClient client = new IopClient(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/ai/image/removal");
request.addApiParameter("image_base64", "Base64");
request.addApiParameter("image_url", "https://ae01.alicdn.com/kf/Sa78257f1d9a34dad8ee494178db12ec8l.jpg");
request.addApiParameter("non_object_remove_elements", "[1,2,3,4]");
request.addApiParameter("object_remove_elements", "[1,2,3,4]");
request.addApiParameter("mask", "474556 160 475356 160 476156 160 476956 160 477756 160 478556 160 479356 160 480156 160 480956 160 481756 160 482556 160 483356 160 484156 160 484956 160 485756 160 486556 160 487356 160 488156 160 488956 160 489756 160 490556 160 491356 160 492156  160");
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);

Response Parameters

NameTypeDescription

resCode

Number

Response code; 200 represents a successful call, other response codes can refer to the error code information.

data

Object

The structure of the returned result.

requestId

String

Request ID; used to identify a unique request call.

success

Boolean

Whether the operation was successful; true for success, false for failure.

resMessage

String

Error message, such as "content has sensitive data, please try other input".

Sample Response

{
  "data": {
    "imageUrl": "https://nhci-aigc.oss-cn-zhangjiakou.aliyuncs.com/ppc-records%2Fimage-remove%2F805fe1d4-8335-4eaa-b4c1-f9952fea21ef.png?OSSAccessKeyId=LTAI5tCv9DpB7gYic1oGsAyv&Expires=4935905309&Signature=eIJOXyUEBoxqb3VtUJF08xFlcgM%3D",
    "usage": 1,
    "width": 800,
    "class": "com.aidc.service.api.client.image.dto.ImageGenResponse",
    "height": 1259
  },
  "requestId": "2140e7df17192333083756998ebc3f",
  "success": true,
  "resCode": 200,
  "resMessage": "success",
  "code": "0",
  "request_id": "2101725817192333083795305",
  "_trace_id_": "2140e7df17192333083756998ebc3f"
}

Errors

Error CodeError MessageDescription

501

rate limit exceed

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

700

invalid input

The input parameter format does not meet the requirements; resMessage will return details.

701

image url error

Failed to Download Image from URL, please retry.

702

image base64 error

Image Base64 Download or Recognition Failed.

703

image size exceeds the limit

The image size exceeds the limit, please provide an image within the limit.

704

invalid image form

The image format is not supported.

705

image file size exceeds the limit

The image file size after parsing should be within 10 MB.

801

model failed

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

900

tpp url error

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

The request contains sensitive information, not supported at the moment, please try other inputs.

1001

content control failed, please retry

Content control service failed, please retry, and please contact us via navigation bar or email us (aidge_support@service.alibaba.com) if the error persists.

1002

content risk filter failed, please contact us

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

Notice

By using this API, you confirm that you are a legal owner of all intellectual property rights pertaining to the data and content that you provide to us via the API, or have obtained the necessary authorizations for us to receive and use the same from you. You further agree that you will not use this product or any output thereof for any unlawful, unethical, unauthorized or harmful activities.

Last updated