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 Cropping
  • Request Parameter
  • Sample Request
  • Response Parameters
  • Sample Response
  • Errors

Was this helpful?

  1. API REFERENCE
  2. E-commerce Image Editing
  3. Image Cropping

Image Cropping API Reference

PreviousImage CroppingNextImage Elements Removal

Last updated 2 months ago

Was this helpful?

Image Cropping

GET/POST /ai/image/cropping

Image Cropping allows you to resize any image to your desired dimensions. It supports automatic recognition of the main area of the image and crops images with precision, ideal for a wide range of design scenarios.

Request Parameter

Parameter
Type
Required
Description

imageUrl

String

No

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

Sample: http://example.jpg/

imageBase64

String

No

Base64 of image

It cannot be empty together with image URL. If both imageUrl and iImageBase64 exist, Base64 is preferred.

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

targetWidth

Int

Yes

Target width of image.

Unit:Pixel. Range:100-5000

Sample: 800

targetHeight

Int

Yes

Target height of image.

Unit:Pixel. Range:100-5000

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/cropping");
request.addApiParameter("targetHeight", "200");
request.addApiParameter("imageUrl", "https://ae01.alicdn.com/kf/S99cb7e78ba2b46cc9134b87c323bb617x.png");
request.addApiParameter("targetWidth", "200");
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": {
    "imageUrl": "https://ai-business-algo-pai.oss-ap-southeast-1.aliyuncs.com/ai_computing%2Ftmp%2F76cfdba6-414c-4cae-9fd8-2f0bedd014ab.png?OSSAccessKeyId=LTAI5tAGoBnm5eYsnZ5E1zMr&Expires=4935905941&Signature=KXlHdonXT6ktAlqw5x5wLHLy9uk%3D",
    "usage": 1,
    "width": 1000,
    "class": "com.aidc.service.api.client.image.dto.ImageGenResponse",
    "height": 1000
  },
  "requestId": "21410ce717192339411452275ea831",
  "success": true,
  "resCode": 200,
  "resMessage": "success",
  "code": "0",
  "request_id": "212a664f17192339411465542",
  "_trace_id_": "21410ce717192339411452275ea831"
}

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 has sensitive data, please try other input. If an error persists,please contact us via navigation bar or email us (aidge_support@service.alibaba.com).

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

https://github.com/Aidge-AI