All Products
Search
Document Center

Intelligent Media Management:DetectImageCropping

Last Updated:Jun 22, 2026

Detects visually optimal cropping regions in an image at a specified aspect ratio by using AI model capabilities.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

imm:DetectImageCropping

none

*Project

acs:imm:{#regionId}:{#accountId}:project/{#ProjectName}

None None

Request parameters

Parameter

Type

Required

Description

Example

ProjectName

string

Yes

The project name.

immtest

SourceURI

string

No

The OSS URI of the image.

The OSS URI follows the format oss://${Bucket}/${Object}, where ${Bucket} is the name of an OSS bucket in the same region as the current project, and ${Object} is the full path of the file including the file name extension.

oss://imm-test/testcases/facetest.jpg

AspectRatios

string

No

The list of cropping aspect ratios. You can specify up to 5 ratios. Each ratio must meet the following requirements:

  • The ratio must consist of integers in the range of (0, 20).

  • The ratio value must be in the range of [0.5, 2].

  • If you do not specify this parameter, the default value ["auto"] is used.

Note

The following cases cause an error:
- More than 5 ratios are specified.
- An empty list is passed.
- The ratio contains non-integer values, such as 4.1:3.
- The ratio value is less than 0.5 or greater than 2.

["1:1"]

CredentialConfig CredentialConfig

No

Leave this parameter empty unless otherwise required.

The China authorization configuration. This parameter is optional. For more information, see Use chained authorization to access resources of other entities.

InclusionHints

array

No

The list of semantic text descriptions for objects that you want the cropping result to include. Each element is free-form text, such as "signboard" or "dish".

Note

Usage limits of the InclusionHints parameter:
- You can pass in up to 1 hint in the array to specify the type of object to include in the cropping result, such as "signboard".
- The algorithm detects all objects in the image that match the hint and generates cropping regions that include as many matched objects as possible.
- Each cropping region includes up to 10 matched objects. If more than 10 objects match in the image, the cropping region includes up to 10 of them.
- You can use the MatchedInclusionHints response field to determine whether the hint was successfully matched.
- This parameter is supported only in regions in the Chinese mainland.

["sign"]

string

No

The semantic text description of an object that you want the cropping result to include.

sign

Response elements

Element

Type

Description

Example

object

The image cropping result.

Croppings

array

The array of image cropping information.

CroppingSuggestion

The detailed cropping information of the image.

RequestId

string

The request ID.

91AC8C98-0F36-49D2-8290-742E24D*****

MatchedInclusionHints

array

The list of objects included in the cropping region, corresponding to the InclusionHints input parameter. This field is empty if no objects are included.

string

The object included in the cropping region.

sign

Examples

Success response

JSON format

{
  "Croppings": [
    {
      "AspectRatio": "2:3",
      "Confidence": 0.742,
      "Boundary": {
        "Width": 200,
        "Height": 300,
        "Left": 10,
        "Top": 30,
        "Polygon": [
          {
            "X": 10,
            "Y": 10
          }
        ]
      }
    }
  ],
  "RequestId": "91AC8C98-0F36-49D2-8290-742E24D*****",
  "MatchedInclusionHints": [
    "sign"
  ]
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.