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

Try it,

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.