Media Server 26.1
Media Server Help

# TrainImageHash

Trains Media Server to identify duplicate images. This adds a new image hash, with a training image, to the training database.

This action is atomic, so that any interruption to the server does not leave the database in an inconsistent state. The database is not modified if the action returns an error, or if you stop it using the QueueInfo action. If training fails, Media Server does not add the image hash to the database.

Type: asynchronous

Parameter | Description | Required
--- | --- | ---
`database` | The name of the database to add the new image hash to. The database must already exist. | Yes
`identifier` | A unique identifier for the image hash (maximum 254 bytes). If you do not set this parameter, Media Server generates an identifier automatically. | No
`imagedata` | The training image to add. Send files to Media Server using a multipart/form-data HTTP POST request. | Set this or `imagepath`
`imagelabel` | 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. | No
`imagepath` | The path to the training image to add. The path must be absolute, or relative to the Media Server executable file. To strengthen security, Media Server can be configured to read files only from specified directories. For information about the directories that Media Server is permitted to read from, see the parameter AllowedInputDirectories. | Set this or `imagedata`
`metadata` | A comma-separated list of metadata key-value pairs to add. Separate keys from values using a colon (`:`). To include a comma or colon in a key name or value, you must enclose the key name or value in quotation marks (`"`) and escape any quotation marks that occur within the string with a backslash (`\`). | No

## Example

The following example trains Media Server by sending the path of a training image using the `imagepath` parameter:

    curl http://localhost:14000 -F action=TrainImageHash
                                -F database=ImageHashes
                                -F identifier=AnImage
                                -F imagepath=image.png

Alternatively, you can train Media Server by sending the image data, for example:

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

## Response

This action is asynchronous, so Media Server always returns success accompanied by a token. You can use this token with the QueueInfo action to retrieve the status of your request.

    <autnresponse>
      <action>QUEUEINFO</action>
      <response>SUCCESS</response>
      <responsedata>
        <actions>
          <action>
            <status>Finished</status>
            <queued_time>2018-Jan-04 09:53:21</queued_time>
            <time_in_queue>0</time_in_queue>
            <process_start_time>2018-Jan-04 09:53:21</process_start_time>
            <time_processing>0</time_processing>
            <process_end_time>2018-Jan-04 09:53:21</process_end_time>
            <build>
              <image>
                <label>AnImage</label>
                <status>trained</status>
              </image>
            </build>
            <database>ImageHashes</database>
            <identifier>AnImage</identifier>
            <numimages>1</numimages>
            <numtrained>1</numtrained>
            <token>.....</token>
          </action>
        </actions>
      </responsedata>
    </autnresponse>

Copyright 2025 Open Text
Version 26.1 | Last updated January 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery Media Server 26.1

Topic Title: TrainImageHash