0

I am trying to do a reverse image search with the Google REST API with an image stored locally. I am using the new--not deprecated--REST API. I can do a text search and get results. I can not do a search with a local image. I can do a reverse image search on the image and get a result. Any suggestions?

My https string is:

https://www.googleapis.com/customsearch/v1?key=A******&cx=0****&q=file:///home/givonz/donald-trump-voicemail-feature.jpg

Also, tried this https string, which doesn't work either:

https://www.googleapis.com/customsearch/v1?key=A******&cx=0****&searchType=image&q=file:///home/givonz/donald-trump-voicemail-feature.jpg

This text string search works:

https://www.googleapis.com/customsearch/v1?key=A******&cx=0****&q=Some+String
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
givonz
  • 187
  • 9
  • Will these information be useful for you? https://stackoverflow.com/questions/12997597/google-reverse-image-search-api https://stackoverflow.com/questions/42484945/google-reverse-image-search-via-api/42495735#42495735 – Tanaike Jan 21 '18 at 23:37

2 Answers2

0

It seems the service is deprecated and no longer available as an API and; it always needed a link (URL). There are a few services on the web that seem to provide the function. Bing, in spite of appearing to do so, doesn't seem to. Yahoo does a reverse image search, but, I couldn't find an API. "Incandescent" does provide this service and with an API.

givonz
  • 187
  • 9
  • Bing does have a reverse image search with POST functionality where you can pass local image. – Ronak Jan 24 '18 at 22:57
  • I am aware of Bing. I did not see an API in their docs. Even using a raw image, didn't return the kind of results I am looking for. For me, ImageRaider is providing good results for links but, not images. Do you have a link for the Bing doc's? – givonz Jan 26 '18 at 10:24
  • Posted answer with sample code. Hope it works for you! – Ronak Jan 27 '18 at 01:24
  • You wouldn't happen to have a Python version would you? :-) – givonz Jan 28 '18 at 00:11
0

This should work. Make sure you pass your key in the header.

var path = @"YOUR_IMAGE_PATH";
var url = "https://api.cognitive.microsoft.com/bing/v7.0/images/details?modules=similarimages";
using (var client = new HttpClient())
using (Stream imageFileStream = File.OpenRead(path))
{
   var content = new MultipartFormDataContent();
   var strContent = new StreamContent(imageFileStream);
   strContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = "anynameworks" };
   content.Add(strContent);

   var message = await client.PostAsync(url, content);
   return await message.Content.ReadAsStringAsync();
}
Ronak
  • 751
  • 5
  • 10