Adding images¶
Requirements¶
- A WineEngine API from https://services.tineye.com/.
- Your server’s IP registered with WineEngine, or a username and password provided by TinEye.
cURL
, a command-line tool used in the examples. If you are not familiar with this tool you can read about and download it from http://curl.haxx.se/. Of course, you don’t have to use cURL but it is a quick way to experiment and familiarize yourself with the API. For production use we highly recommend using one of our libraries.
Adding images¶
The first thing to do when we have your WineEngine API set up is to add some images to it. That gives you a collection to search!
Images are added to your API one at a time using the add method.
Images can be added by uploading an image file or by giving the server a URL from which
the image can be downloaded. In this example, we add an image by specifying a URL to
download it from. In all of the examples replace <company>
with your WineEngine account name.
If you are using password-based authentication, you must also add your username and password,
like https://username:password@wineengine
...
curl https://wineengine.tineye.com/<company>/rest/add/ \
-F "url=https://img.tineye.com/samples/tutorials/joca_label.jpg" \
-F "filepath=example1.jpg"
The curl command creates a POST request which sends two parameters,
url and filepath, to your WineEngine API. The url parameter specifies the
location from which the server will download the image. The filepath parameter specifies
the name by which the image will be known in your API after it has been downloaded; in this case, example1.jpg
.
The name can be any string you like, and does not have to end with .jpg
.
If there are no errors the server should reply with:
{
"status": "ok",
"error": [],
"method": "add",
"result": []
}
If any problems had occurred they would have been detailed in the error list.
To add more images to your API you just send the same command again with updated url and filepath parameters. Here are two more cURL calls:
curl https://wineengine.tineye.com/<company>/rest/add/ \
-F "url=https://img.tineye.com/samples/tutorials/joca_bottle.jpg" \
-F "filepath=example2.jpg"
curl https://wineengine.tineye.com/<company>/rest/add/ \
-F "url=https://img.tineye.com/samples/tutorials/tarapaca_bottle.jpg" \
-F "filepath=example3.jpg"
After running those two commands you will have three images in your API, ready for searching.
Images can also be uploaded directly to the server from a cURL request. To do that, you would not use the url parameter but would instead use the image parameter to specify an image file to upload.
The complete description of the add request is available at POST add.
Here is what the example images used above look like. Note that they have been pre-scaled to the recommended size, 1000 pixels in the smallest dimension:
example1.jpg

example2.jpg

example3.jpg

Now that you have images loaded, you can go to the next tutorial: Searching.