We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,530 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Using Bing Search Api to perform a advanced image search ?

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........

2
Contributors
4
Replies
2 Days
Discussion Span
3 Years Ago
Last Updated
5
Views
Question
Answered
Damon88
Newbie Poster
20 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Try it,

request.Query="dani site:daniweb.com"
request.Image.Filters = new string(){"Size:Width:200","Size:Height:200"}
__avd
Posting Genius (adatapost)
Moderator
8,736 posts since Oct 2008
Reputation Points: 2,141
Solved Threads: 1,262
Skill Endorsements: 50

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....

Damon88
Newbie Poster
20 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

__avd
Posting Genius (adatapost)
Moderator
8,736 posts since Oct 2008
Reputation Points: 2,141
Solved Threads: 1,262
Skill Endorsements: 50

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 ......

Damon88
Newbie Poster
20 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 3 Years Ago by __avd

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0910 seconds using 2.65MB