This topic describes four methods that you can use to add images. You can add images
by calling API operations, using SDKs, performing batch operations, and using the
console. Use SDKs if you need to add a small number of images in real time. Perform
batch operations if you need to add millions of images by using a task. Use the console
if you want to experience how to add images to the image gallery in Image Search.
You can select an appropriate method based on your business needs.
Use the console
- Log on to the Image Search console.
- In the left-side navigation pane, select the service type that you need.
For more information about the service types, see
Features.

- Click the required instance ID.
- Click the Add Image tab.

Specify the parameters to add an image based on the following parameter descriptions.
Parameter |
Parameter name in API operations |
Description |
Required |
Commodity ID |
ProductId |
The unique ID of the product. The ID can be up to 512 characters in length. |
Yes |
Image Name |
PicName |
The name of the image. The name can be up to 512 characters in length.
Note
- An image is uniquely identified by a combination of the product ID and the image name.
- If images have the same product ID and image name, only the latest image prevails.
|
Yes |
Upload Image |
PicContent |
The image file to be uploaded. The image file is encoded in Base64. The image to be
uploaded must meet the following requirements:
- The file size of the image cannot exceed 4 MB.
- Image Search supports the following image formats: PNG, JPG, JPEG, BMP, GIF, WEBP,
TIFF, and PPM.
- The transmission time-out period cannot exceed 5 seconds.
- For product, and generic image searches, the length and the width of the image must
range from 100 pixels to 4,096 pixels.
- The image cannot contain rotation information.
|
Yes |
Image Subject Recognition |
Crop |
Specifies whether to recognize the subject in the image and search for images based
on the recognized subject.
|
Yes |
Recognition Method |
- |
The method to recognize the subject in the image. Valid values:
- Automatic Recognition: If you select this option, the system recognizes the subject
and searches for images based on the recognized subject. You can obtain the recognition
result in the response.
- Define the main subject area: You can specify an area for subject recognition. If
you do not specify a subject area, the system searches for images based on the entire
image.
|
Yes |
Image Category |
CategoryId |
The category of the image. You can specify the category of an image when you add the
image.
|
No |
Custom Content |
CustomContent |
The user-defined content. The value can be up to 4,096 characters in length. |
No |
Integer Attribute |
IntAttr |
The integer attribute. The attribute can be used to filter images when you search
for images.
|
No |
String Attribute |
StrAttr |
The string attribute. The value can be up to 128 characters in length. The attribute
can be used to filter images when you search for images.
|
No |
- Click OK. The process of adding the image is completed.
Call API operations
In this method, you can send requests over HTTP or HTTPS to access Image Search, and
you must be authenticated based on a signature mechanism. The request body must be
sent in a specified format. By default, five queries per second (QPS) are supported
if you add images by calling API operations. For more information, see Add images.
Use SDKs
Image Search provides SDKs of multiple versions. If you use SDKs to add images, you
do not need to concern yourself with issues such as signature verification and compliance
with the format of the request body. If you add a small number of images in real time,
we recommend that you use SDKs. By default, five QPS is supported if you add images
by using SDKs. For more information, see SDK reference.
Perform batch operations
After you connect Image Search to Alibaba Cloud Object Storage Service (OSS), you
can import images from OSS to Image Search in batches. This method applies to scenarios
where you need to add millions of images by using a task. For more information, see
Perform batch operations.