All Products
Search
Document Center

Image Search:Add images

Last Updated:Sep 14, 2023

This topic describes four methods that you can use to add images to Image Search. You can add images by using the Image Search console, calling the AddImage operation, using Image Search SDKs, or using the batch operation feature. Use the Image Search console if you want to experience how to add an image. Use Image Search SDKs if you want to add a small number of images in real time. Use the batch operation feature if you want to add millions of images at a time. You can select an appropriate method based on your business requirements.

Prerequisites

An Image Search instance is created. For more information, see Activate Image Search.

Use the Image Search console

  1. Log on to the Image Search console.

  2. In the left-side navigation pane, select a service type. In this example, Product Search Instances is selected.

    For more information about service types, see the Features section of the "What is Image Search?" topic.ๅ•†ๅ“ๆœ็ดข

  3. Click the ID of the instance that you want to manage.

    2
  4. On the Instance Details page,click the Add Image tab.

    3The add image parameter settings are as follows.

    Parameter

    Parameter name in the AddImage operation

    Description

    Required

    Commodity ID

    ProductId

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

    Yes

    Image Name

    PicName

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

    Note

    An image is uniquely identified by a combination of the product ID and the image name.

    Important

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

    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.

    • The image is in one of the following formats: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.

    • The transmission timeout period cannot exceed 5 seconds.

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

    • The image cannot contain rotation settings.

    Important

    This parameter requires you to directly upload the image file that is encoded in Base64. For more information about how to upload an image by specifying the image URL, see the Add section of the "SDK for Java" topic.

    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

    N/A

    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.

    Note
    1. A built-in automatic category prediction feature is provided for product image searches. If you do not specify a category for the image, the system automatically predicts the category of the image and indexes the predicted category into the engine. The prediction result is returned in the response.

    2. During product image searches, the system also automatically predicts the category of the image that you upload and searches for images based on the predicted category to narrow the search scope and improve the search accuracy.

    3. For product image searches, we recommend that you use the default automatic category prediction feature.

    4. For cloth image searches, brand image searches, generic image searches, copyrighted image searches, industrial hardware image searches, and furniture and household supply image searches, 88888888 is returned as the category ID in the response regardless of whether a category is specified.

    5. For more information about categories, see Category reference.

    Important

    If you specify a category for an image when you upload the image, you must specify the same category for image searches when you search for images. Otherwise, the source image of the image that you upload cannot be searched for.

    No

    Custom Content

    CustomContent

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

    Note

    The user-defined content of the image is automatically returned in the search results. You can add information such as the image URL and image description by using this parameter.

    No

    Integer Attribute

    IntAttr

    An integer-type attribute of the image. The attribute can be used to filter images when you search for images.

    Note

    When you search for images, you can specify the Integer Attribute parameter and filter conditions to filter images. For more information, see Search for images by specifying filter conditions.

    No

    Integer Attribute2

    IntAttr2

    An integer-type attribute of the image. The attribute can be used to filter images when you search for images.

    Note
    • When you search for images, you can specify the Integer Attribute2 parameter and filter conditions to filter images. For more information, see Search for images by specifying filter conditions.

    • This parameter is displayed only for instances that are created after January 3, 2023.

    No

    String Attribute

    StrAttr

    A string-type attribute of the image. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images.

    Note

    When you search for images, you can specify the String Attribute parameter and filter conditions to filter images. For more information, see Search for images by specifying filter conditions.

    No

    String Attribute2

    StrAttr2

    A string-type attribute of the image. The value can be up to 128 characters in length. The attribute can be used to filter images when you search for images.

    Note
    • When you search for images, you can specify the String Attribute2 parameter and filter conditions to filter images. For more information, see Search for images by specifying filter conditions.

    • This parameter is displayed only for instances that are created after January 3, 2023.

    No

  5. Click OK.

Call the AddImage operation

You can add images by sending requests over HTTP or HTTPS to call the AddImage operation of Image Search. In this method, a signature is used to authenticate the requester, and the request body must be sent in the specified format. The default queries-per-second (QPS) limit on calling the AddImage operation is 5 QPS. For more information, see AddImage.

Use Image Search SDKs

Image Search provides SDKs of multiple versions. If you use Image Search 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 want to add a small number of images in real time, we recommend that you use Image Search SDKs. If you add images by using Image Search SDKs, the QPS limit is 1 QPS for instances whose image capacity specifications are 0.1 million images, and 5 QPS for instances of other image capacity specifications. For more information, see the Add section of the "SDK for Java" topic.

Use the batch operation feature

After you connect Image Search to Object Storage Service (OSS), you can import multiple images from OSS to Image Search at a time. This method is suitable for scenarios in which you want to add millions of images at a time. For more information, see Perform batch operations.