DetectImageCropping

更新时间:
复制 MD 格式

Detects a visually optimal cropping box in an image for a specified aspect ratio.

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 URI must be in the format oss://${Bucket}/${Object}, where ${Bucket} is the name of an OSS bucket in the same region as your project, and ${Object} is the full path of the object, including the file extension.

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

AspectRatios

string

No

A list of aspect ratios for cropping. You can specify up to five ratios. The following requirements apply to each aspect ratio:

  • The ratio must be in the format width:height, where both width and height are integers from 1 to 19.

  • The value of the ratio (width divided by height) must be between 0.5 and 2, inclusive.

  • If you omit this parameter, the default is ["auto"].

Note

An error occurs in the following cases:
- More than five aspect ratios are specified.
- The specified list is empty.
- A ratio contains non-integer values, such as 4.1:3.
- The value of a ratio is less than 0.5 or greater than 2.



["1:1"]

CredentialConfig CredentialConfig

No

Leave this parameter empty unless you have specific authorization requirements.

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

InclusionHints

array

No

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

Note

The InclusionHints parameter has the following limitations:
- You can specify only one element.
- This parameter is supported only in regions in the Chinese mainland.

["sign"]

string

No

A 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 results.

Croppings

array

An array of suggested crops.

CroppingSuggestion

The details of a suggested crop.

RequestId

string

The request ID.

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

MatchedInclusionHints

array

A list of hints from the InclusionHints parameter that were matched in the cropping box. If no hints are matched, this list is empty.

string

A hint matched in the cropping box.

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.