1
$\begingroup$

I'd like to download highest resolution images possible from the search results like these:

links = {"https://www.bing.com/images/search?q=spikey&FORM=HDRSC2", "https://www.google.com/search?site=&tbm=isch&source=hp&biw=1280&bih=778&q=spikey&oq=spikey&gs_l=img"}

It seems that what I'm doing here:

(Import /@ Import[#, "ImageLinks"])& /@ links

downloads lots of low resolution images, is there a better way to do this?

$\endgroup$
2
$\begingroup$

This might help but it doesn't filter the images explicitly.

First get the links from Google to the sites where these images are located,

linksFromGoogle=Import["https://www.google.com/search?site=&tbm=isch&source=hp&biw=1280&bih=778&q=spikey&oq=spikey&gs_l=img", "Hyperlinks"]

Then filter these links so you get links that lead to sites with images (outside of Google)

linksToIndivualWebsites = Flatten[StringCases[linksFromGoogle,"https://www.google.com/url?q=" ~~data___ :> data, Infinity]]

Then from one site get the image links (you could map over the linksToIndivualWebsites list to get all of the image links from all sites

Then get the images links from one site

linksToImageLinksFromOneSite = Import[linksToIndivualWebsites[[1]], "ImageLinks"]

Then download the images from that site (this could also be mapped over all the images and all the sites)

imagesFromOneSite = Import[#] & /@ linksToImageLinksFromOneSite

There might be a better way there...

You could put all this in a module...but then you would get a lot of images that are not what you are looking for. You might be able to do some machine learning to discard the images that are not useful to you.

$\endgroup$
  • $\begingroup$ You could then use the meta data from each image to determine the quality. I don't know if there is a way to do that before you download the image. I thought that the images on the individual sites would have higher quality images than the "ImageLinks" from Google Search result. $\endgroup$ – Ray Troy Apr 20 '15 at 17:09
  • $\begingroup$ Good idea, I'm not sure either, but this is a nice start. $\endgroup$ – M.R. Apr 20 '15 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.