All Products
Search
Document Center

Image Search:CompareSimilarByImage

Last Updated:Jan 09, 2026

Compares the similarity values of two images.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

CompareSimilarByImage

The operation that you want to perform. Set the value to CompareSimilarByImage.

PrimaryPicContent

String

Yes

AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=

The image.

  • The image size cannot exceed 4 MB.

  • The following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.

  • The transmission timeout period cannot exceed 5 seconds.

  • For product and generic image searches, the length and width of the image must range from 100 pixels to 4,096 pixels.

  • The image cannot contain rotation settings.

Note

Use the SDK to call the operation:

  • Only Image Search SDK V3 is supported. You do not need to specify PrimaryPicContent. The SDK encapsulates this parameter into PrimaryPicContentObject and automatically encodes its value in Base64. For more information about the sample code, see SDK for Java.

  • If you use Image Search SDK to call this operation, you cannot upload an image by specifying the image URL. If you use Image Search SDK V3, you can upload an image file. For more information about the sample code, see SDK for Java.

SecondaryPicContent

String

Yes

AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=

The image.

  • The image size cannot exceed 4 MB.

  • The following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.

  • The transmission timeout period cannot exceed 5 seconds.

  • For product and generic image searches, the length and width of the image must range from 100 pixels to 4,096 pixels.

  • The image cannot contain rotation settings.

Note

Use the SDK to call the operation:

  • Only Image Search SDK V3 is supported. You do not need to specify PrimaryPicContent. The SDK encapsulates this parameter into PrimaryPicContentObject and automatically encodes its value in Base64. For more information about the sample code, see SDK for Java.

  • If you use Image Search SDK to call this operation, you cannot upload an image by specifying the image URL. If you use Image Search SDK V3, you can upload an image file. For more information about the sample code, see SDK for Java.

InstanceName

String

Yes

demoinstance1

The name of the Image Search instance. The name can be up to 20 characters in length.

If an Image Search instance is purchased, you can log on to the Image Search console to view the instance.

If no Image Search instance is purchased, you must purchase an instance. For more information, see Activate Image Search and Create an Image Search instance.

Note

This parameter indicates the instance name rather than the instance ID.

Response parameters

Parameter

Type

Example

Description

Score

double

0.85

The similarity score of the image. Valid values: 0 to 1.

Success

Boolean

true

Indicates whether the request was successful.

RequestId

String

B3137727-7D6E-488C-BA21-0E034C38A879

The request ID.

Msg

String

success

The error message.

AccessDeniedDetail

Object

The information returned for authentication.

AuthAction

String

xxx

The operation used for authentication.

AuthPrincipalDisplayName

String

111

The authentication principal.

AuthPrincipalOwnerId

String

222

The ID of the Alibaba Cloud account to which the authentication principal belongs.

AuthPrincipalType

String

SubUser

The principal type that is used for authentication.

EncodedDiagnosticMessage

String

xxxxxx

The complete encrypted diagnosis information.

NoPermissionType

String

ImplicitDeny

ImplicitDeny: No policy is hit.

ExplicitDeny: The Deny policy is hit.

PolicyType

String

AccountLevelIdentityBasedPolicy

The type of the policy that causes the access denied error.

Code

Integer

0

The error code.

  • The value 0 indicates that the request was successful.

  • Values other than 0 indicate that the request failed.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CompareSimilarByImage
&PrimaryPicContent=AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=
&SecondaryPicContent=AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=
&InstanceName=demoinstance1
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CompareSimilarByImageResponse>
    <Score>0.85</Score>
    <Success>true</Success>
    <RequestId>B3137727-7D6E-488C-BA21-0E034C38A879</RequestId>
    <Msg>success</Msg>
    <AccessDeniedDetail>
        <AuthAction>xxx</AuthAction>
        <AuthPrincipalDisplayName>111</AuthPrincipalDisplayName>
        <AuthPrincipalOwnerId>222</AuthPrincipalOwnerId>
        <AuthPrincipalType>SubUser</AuthPrincipalType>
        <EncodedDiagnosticMessage>xxxxxx</EncodedDiagnosticMessage>
        <NoPermissionType>ImplicitDeny</NoPermissionType>
        <PolicyType>AccountLevelIdentityBasedPolicy</PolicyType>
    </AccessDeniedDetail>
    <Code>0</Code>
</CompareSimilarByImageResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Score" : 0.85,
  "Success" : true,
  "RequestId" : "B3137727-7D6E-488C-BA21-0E034C38A879",
  "Msg" : "success",
  "AccessDeniedDetail" : {
    "AuthAction" : "xxx",
    "AuthPrincipalDisplayName" : "111",
    "AuthPrincipalOwnerId" : "222",
    "AuthPrincipalType" : "SubUser",
    "EncodedDiagnosticMessage" : "xxxxxx",
    "NoPermissionType" : "ImplicitDeny",
    "PolicyType" : "AccountLevelIdentityBasedPolicy"
  },
  "Code" : 0
}

Error codes

HttpCode

Error code

Error message

Description

400

SearchTimeout

The request timed out.

The request timed out.

400

TimeoutForTransferImage

Image transfer timed out.

Image transmission on the client timed out.

400

UnsupportedPicFormat

The specified image format is invalid.

The image format is invalid.

400

UnsupportedPicPixels

The specified pixels is not supported.

The specified image pixel value is not supported.

400

UnsupportedPictureFormat

The format of the specified picture is not supported.

The image format is not supported

400

Console.InstanceNotFound

The specified ImageSearch instance is not found.

The instance cannot be found. Check the instance ID.

400

Console.PidError

The number of PID bindings of the current instance exceeds 50.

The number of process identifiers (PIDs) bound to the current instance exceeds 50.

400

EmptyMeta

The body content has an empty meta field.

The request body contains empty parameters.

400

IncorrectOrientation

The image contains incorrect rotation flags in the meta data.

The image carries rotation settings. Rotation settings are not supported.

400

InstanceOverQuota

The number of items exceeds the limit.

The number of images in the instance exceeds the upper limit.

400

InstanceStatusError

The current instance status does not support this operation.

The error message returned because the instance is unavailable.

400

InvalidInstance

The specified instance name is invalid.

The instance name is invalid.

400

InvalidPicContent

The image size exceeds 4 MB.

The image size exceeds 4 MB.

400

InvalidPicUrl

The specified parameter PicUrl is not valid.

The PicUrl parameter is invalid.

400

NeedRegisterBeforeInvoke

Register for PID before invoking the service.

You must register a PID before calling the operation.

400

NoCaretSeperator

The body content is missing the ^ separator.

Specific symbols are missing in the request body.

400

NoSpecifiedPic

The content of an image is not specified in the HTTP POST body.

No image is specified.

400

PicNotExist

The specified image does not exist.

No image is specified.

400

InvalidSecondaryPicContent

The specified parameter SecondaryPicContent is not valid.

The SecondaryPicContent is invalid.

400

InvalidPrimaryPicContent

The specified parameter PrimaryPicContent is not valid.

The PrimaryPicContent is invalid.

400

PictureError

[download] Img Download Failed.

Failed to download the image. Check it and try again.

400

UnsupportedInstanceType

The instance type is not supported.

The instance type is not supported.

400

UnsupportedOperationType

The specified action is not supported.

The specified operation is not supported.

403

Console.NoPermissionError

You are not authorized to perform this operation.

You do not have the permissions to perform the operation.

403

Console.NotAllowedModifyToken

You are not allowed to modify token today.

You are not allowed to modify the token value today.

403

DeniedRequest

Your request was denied due to instance flow control.

Your request was denied due to throttling.

403

NoPermission

You are not authorized to perform this operation.

The error message returned because you are not authorized to perform this operation.

409

Console.TaskAlreadyExist

A task that is in progress already exists.

The error message returned because a task is already in progress.

500

ServerInternalError

An internal error occurred.

An internal error has occurred.

500

UnknownException

An internal server error occurred.

An unknown error has occurred.

500

AccessEngineFailed

An error occurred while accessing the search engine.

An error has occurred in the search engine.

500

ConnectionDVException

Failed to obtain collection.

internalError

500

Console.CallServiceError

An internal service error occurred.

The error message returned because an internal error occurred.

500

ExtractFeatureTimeout

The request timed out while extracting features.

The feature extraction timed out.

500

InternalOssError

An internal OAS error occurred.

An internal algorithm error has occurred.

500

InternalSwiftError

An internal SWIFT error occurred.

An internal message queue error has occurred.

500

InternalTableStoreError

An internal Table Store error occurred.

An internal storage error has occurred.

500

NetworkException

A network error occurred.

A network error has occurred.

500

RequestTimeout

The request timed out.

The request timed out.

For a list of error codes, see Service error codes.