AddImage

更新时间:
复制 MD 格式

This topic describes the syntax of the AddImage operation and provides examples of this operation. You can call this operation to add an image to an Image Search instance.

Usage notes

You can call this operation to add an image to an Image Search instance.

QPS limits

The default concurrency for adding an image to instances with a capacity of 100,000 images is 1. This means that the system can process up to one image upload request per second.

The default concurrency for adding an image to instances with other image capacity specifications is 5. This means that the system can process up to five image upload requests per second.

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

AddImage

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

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

The instance name is not the instance ID.

ProductId

String

Yes

2092061_1

The ID of the product. The ID can be up to 256 characters in length.

Note

A product may have multiple images.

PicName

String

Yes

2092061_1.jpg

The name of the image. The name can be up to 256 characters in length.

Note
  • An image is uniquely identified by the values of the ProductId and PicName parameters.

  • If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image.

PicContent

String

Yes

AAAANSUhEUgAAAPcAAAEVCAYAAAA8d3NuAAAAAXNSR0IArs......RK5CYII=

The image content.

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

  • 服务类型为商品图片搜索、通用图片搜索、家具家居图片搜索和工业五金图片搜索时,图片长和宽像素要求大于等于100PX且小于等于4096PX。

    服务类型为商标图片搜索时,图片长和宽像素要求大于等于200PX且小于4096PX。

    服务类型为布料图片搜索时,图片长和宽像素要求大于等于448PX且小于等于4096PX。

  • The image cannot contain rotation settings.

Note
  • Use the SDK to call the operation:

    • If you use Image Search SDK V3 to call the operation, you can upload an image without the need to specify PicContent. The SDK encapsulates PicContent into PicContentObject 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. For more information about the sample code, see SDK for Java.

  • Use OpenAPI Explorer to call the operation:

    • If the API version is 2019-03-25, enter the Base64-encoded string of an image as the value of PicContent.

    • If the API version is 2020-12-14, upload an image when you specify PicContent.

CategoryId

Integer

No

88888888

The category ID of the image. For more information, see Category reference.

Note
  • For product image search, if you specify a category for an image, the specified category prevails. If you do not specify a category for an image, the system predicts the category, and returns the prediction result in the response.

  • 对于布料、商标、通用、家具家居和工业五金搜索,不论是否设置类目,系统会将类目设置为88888888。

  • For generic image search, 88888888 is returned for this parameter in the response regardless of whether a category is specified.

Crop

Boolean

No

true

Specifies whether to identify the subject in the image and search for images based on the subject identification result. Default value: true. Valid values:

  • true: The system identifies the subject in the image, and searches for images based on the subject identification result. You can obtain the subject identification result from the response.

  • false: The system does not identify the subject in the image, and searches for images based on the entire image.

对于布料图片搜索,此参数会被忽略,系统会以整张图进行搜索。

Region

String

No

280,486,232,351

The subject area of the image, in the format of x1,x2,y1,y2. x1 and y1 represent the upper-left point. x2 and y2 represent the lower-right point.

Note
  • If you specify Region, the system searches for images based on the value of Region regardless of the value of Crop.

  • 对于布料图片搜索,此参数会被忽略,系统会以整张图进行搜索。

  • The value of Region does not have a unit. The value is generated based on the length and width of the image. If the length and width of the image are scaled, the value of Region must be proportionally scaled.

CustomContent

String

No

zidingyi

The user-defined content. The value can be up to 4,096 characters in length.

Note

If you specify this parameter, the response includes this parameter and its value. You can add text such as an image description.

IntAttr

Integer

No

22

The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

StrAttr

String

No

ss

The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

Note

The value cannot contain the following special characters: \ ¥ $ & %

IntAttr2

Integer

No

22

The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

StrAttr2

String

No

ss

The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

Note

The value cannot contain the following special characters: \ ¥ $ & %

IntAttr3

Integer

No

33

The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

StrAttr3

String

No

ss

The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

Note

The value cannot contain the following special characters: \ ¥ $ & %

IntAttr4

Integer

No

44

The attribute, which is an integer. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

StrAttr4

String

No

ss

The attribute, which is a string. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images. If you specify this parameter, the response includes this parameter and its value.

Note

The value cannot contain the following special characters: \ ¥ $ & %

Response parameters

Parameter

Type

Example

Description

Message

String

success

The error message.

Note

No value is returned if the request was successful, and an error message is returned if the request failed.

RequestId

String

E0845DE6-52AF-4B50-9F15-51ED4044E6AB

The request ID.

Code

Integer

0

The error code.

  • A value of 0 indicates that the request was successful.

  • Values other than 0 indicate that the request failed.

PicInfo

Object

The results of category prediction and subject recognition.

Region

String

94,691,206,650

The result of subject identification. The subject area of the image is in the format of x1,x2,y1,y2. x1 and y1 represent the upper-left point. x2 and y2 represent the lower-right point. If a subject area is specified in the request, the specified subject area prevails.

CategoryId

Integer

88888888

The result of category prediction. If a category is specified in the request, the specified category prevails.

Success

Boolean

true

Indicates whether the request is successful. Valid values:

Examples

Sample requests

{
        "InstanceName": "demoinstance",
        "PicName": "test",
        "CustomContent": "demo content",
        "PicContent": "${Base64ImageContent}",
        "ProductId": "test",
        "IntAttr": "0",
        "StrAttr": "demo str attr"
    }

Sample success responses

JSON format

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

{
  "PicInfo" : {
    "Region" : "111,697,XX,XX",
    "CategoryId" : 0
  },
  "Message" : "success",
  "RequestId" : "B253A127-DF89-4DDC-A295-618DD22B00B2",
  "Success" : true,
  "Code" : 0
}

Error codes

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