# Add an Image Hash to a Database

To add a new image hash and train Media Server to identify duplicate images, follow these steps.

To add an image hash to a database

- Add the image hash using the action `TrainImageHash`, with the following parameters:

  `database` | The name of the database to add the image hash to. The database must already exist.
  `identifier` | (Optional) A unique identifier for the image hash (maximum 254 bytes). If you do not set this parameter, Media Server generates an identifier automatically.
  `imagedata` | (Set this or `imagepath`, but not both). The training image to add. The file must be uploaded as multipart/form-data. For more information about sending data to Media Server, see Send Data by Using a POST Method.
  `imagepath` | (Set this or `imagedata`, but not both). The path of the training image to add. The path must be absolute or relative to the Media Server executable file.
  `imagelabel` | (Optional) A label to identify the image that you are adding (maximum 254 bytes). If you do not set this parameter, Media Server generates a label automatically.

  For example:

      curl http://localhost:14000 -F action=TrainImageHash
                                  -F database=ImageHashes
                                  -F imagedata=@image1.png

  Alternatively, provide the path of the training image:

      curl http://localhost:14000 -F action=TrainImageHash
                                  -F database=ImageHashes
                                  -F imagepath=./training/image1.png

  Media Server adds the image hash to the database and returns the identifier.

© Copyright 2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm