1,105,546 Community Members

Using Bing Search Api to perform a advanced image search ?

Member Avatar
Damon88
Newbie Poster
20 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I am developing a application in which i need to get images from a search engine. there are many choices to do that google,yahoo, bing etc. I chose bing simply because microsoft provides tight integration with bing and it offers more functionality to developers. So after searching some more i learned how to use this service in my application. Created a key and added web service reference in my solution.

the sample code to get images from the internet is written below.

Try
            ListBox1.Items.Clear()
            Dim service As New LiveSearchPortTypeClient
            Dim request As New BingService.SearchRequest

            With request
                .Query = TextBox1.Text
                .AppId = "please fill your app id here"
                .Sources = New BingService.SourceType() {BingService.SourceType.Image}
               
            End With

            Dim response As BingService.SearchResponse = service.Search(request)
  
            For Each thumburl As BingService.ImageResult In presponse.Image.Results

                ListBox1.Items.Add(thumburl.Thumbnail.Url)
                ListBox1.Items.Add(thumburl.MediaUrl)

            Next

        Catch ex As Exception

        End Try

Now i come to the point, i want to perform a advanced search.

I want to search image using these parameters

>A pre defined size of images
>Search on a particular site

But i cant figure out how to do that, after a lot of searching i came up with this link here
http://msdn.microsoft.com/en-us/library/dd560913.aspx

I am unable to use it. If i use it no results are returned.

Besides this article i cannot find any useful information in the form of a working sample or anything.

Can someone help me with this........

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

Try it,

request.Query="dani site:daniweb.com"
request.Image.Filters = new string(){"Size:Width:200","Size:Height:200"}
Member Avatar
Damon88
Newbie Poster
20 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Try it,

request.Query="dani site:daniweb.com"
request.Image.Filters = new string(){"Size:Width:200","Size:Height:200"}

the Site filter seems to work, thanks for that

but still cannot filter depending on size

request.Image.Filters = new string(){"Size:Width:200","Size:Height:200"}

the above code gives error, and if i do this

dim filters() as string = {"Size:Width:200","Size:Height:200"}
request.Image.Filters = filters

the above code is error free but even that doesnt help, no results are returned....

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

I think you should have to look at these samples - http://msdn.microsoft.com/en-us/library/dd250890.aspx

Member Avatar
Damon88
Newbie Poster
20 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I think you should have to look at these samples - http://msdn.microsoft.com/en-us/library/dd250890.aspx

hey, at last it worked, turned out it was my silly mistake.

Only thing need to be done was to first create

Dim imreq As BingService.ImageRequest = New BingService.ImageRequest
 Dim fil() As String = {"Aspect:Tall"}
                imreq.Filters =fil
                imreq.Count = 20
                imreq.CountSpecified = True
                .Image = imreq

and thats it ......

Question Answered as of 4 Years Ago by __avd
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: