Function Repository Resource:

FirstWebImage

Source Notebook

Get a single image from a web search

Contributed by: Bob Sandheinrich

ResourceFunction["FirstWebImage"][query]

retrieves an image for the specified query.

ResourceFunction["FirstWebImage"][query,elems]

gives the elements of the web image search specified by elems.

Details and Options

ResourceFunction["FirstWebImage"] requires internet connectivity and uses external services that require Service Credits.
The query can be any form supported by WebImageSearch.
The elems can be any element supported by WebImageSearch or their singular form, such as "Thumbnail" and "Image".
The default element is "Thumbnail".

Examples

Basic Examples (2) 

Get a thumbnail image from a web search:

In[1]:=
ResourceFunction["FirstWebImage"]["Ultimate Frisbee"]
Out[1]=

Retrieve a full image:

In[2]:=
ResourceFunction["FirstWebImage"]["Toasted Ravioli", "Image"]
Out[2]=

Scope (2) 

Get the URL for the image:

In[3]:=
url = ResourceFunction["FirstWebImage"]["Wolfram Spikey", "ImageHyperlink"]
Out[3]=

Open it in a browser:

In[4]:=
SystemOpen[url]

Applications (1) 

Find out what a colonial revolutionary looked like (or at least find someone with their name):

In[5]:=
AssociationMap[ResourceFunction["FirstWebImage"],
 ResourceData["Paul Revere's Social Network in Colonial Boston"][
  1 ;; 10, "Name"]]
Out[5]=

Properties and Relations (2) 

The result of FirstWebImage is equivalent to taking the first result of WebImageSearch:

In[6]:=
ResourceFunction["FirstWebImage"]["Baseball"]
Out[6]=
In[7]:=
First@WebImageSearch["Baseball"]
Out[7]=

FirstWebImage is simpler and faster for getting a single image:

In[8]:=
{AbsoluteTiming[
  ResourceFunction["FirstWebImage"]["Aardvark", "Image"]], AbsoluteTiming[First@WebImageSearch["Aardvark", "Images"]]}
Out[8]=

Version History

  • 1.0.0 – 14 August 2019

License Information