Function Repository Resource:

GetUnsplashImage

Source Notebook

Get a picture from the Unsplash free image stock

Contributed by: Daniel de Souza Carvalho

ResourceFunction["GetUnsplashImage"][]

retrieves a random 800×600 image.

ResourceFunction["GetUnsplashImage"][arg]

retrieves an image based on the text query arg.

ResourceFunction["GetUnsplashImage"][{arg1,arg2,}]

retrieves an image based on the argi.

ResourceFunction["GetUnsplashImage"][arg,size]

retrieves an image of width and height specified by size.

Details and Options

The size parameter can be given as a number or as a list of the form {width,height}.
ResourceFunction["GetUnsplashImage"] requires an internet connection.
Unsplash is an internet source of freely usable images powered by creators.
ResourceFunction["GetUnsplashImage"] calls the Unsplash web API.
As ResourceFunction["GetUnsplashImage"] uses an external web API, the performance depends on your connection quality.
Your firewall should allow HTTP/S requests.

Examples

Basic Examples (1) 

Get a random image:

In[1]:=
ResourceFunction["GetUnsplashImage"][]
Out[1]=

Scope (8) 

Get an image that is a portrait:

In[2]:=
ResourceFunction["GetUnsplashImage"]["portrait"]
Out[2]=

Get an image of a turtle:

In[3]:=
ResourceFunction["GetUnsplashImage"]["Turtle"]
Out[3]=

Get an image based on a location and additional details:

In[4]:=
ResourceFunction["GetUnsplashImage"][{"fog", "london"}]
Out[4]=

Get an image based on text hints:

In[5]:=
ResourceFunction["GetUnsplashImage"][{"USA", "flag"}]
Out[5]=

Get an image with a specific squared size:

In[6]:=
ResourceFunction["GetUnsplashImage"]["Brazil", 300]
Out[6]=

Get images of specified width and height:

In[7]:=
ResourceFunction["GetUnsplashImage"]["Florest", {800, 100}]
Out[7]=

In[8]:=
ResourceFunction["GetUnsplashImage"]["Coronavirus", {500, 350}]
Out[8]=
In[9]:=
ResourceFunction["GetUnsplashImage"]["Coronavirus", 245]
Out[9]=

Specify image categories and also width and height:

In[10]:=
ResourceFunction[
 "GetUnsplashImage"][{"Brazil", "beach", "black and white"}, {300, 200}]
Out[10]=

Neat Examples (5) 

You can use any Wolfram Language function to study and analyze the image:

In[11]:=
ResourceFunction["GetUnsplashImage"][]
Out[11]=
In[12]:=
DominantColors[%]
Out[12]=

It is possible to nest this function with any other Wolfram Language function:

In[13]:=
EdgeDetect[
 Blur[ResourceFunction["GetUnsplashImage"]["flower"], .5], .5]
Out[13]=

All advanced image processing functions can be used and combined:

In[14]:=
ResourceFunction["GetUnsplashImage"]["landscape"]
Out[14]=
In[15]:=
ColorSeparate[%] // GraphicsGrid[{#}] &
Out[15]=

You can use those images to test and train machine learning functions in artificial intelligence projects:

In[16]:=
ResourceFunction["GetUnsplashImage"]["People"]
Out[16]=
In[17]:=
FacialFeatures[%] // Dataset
Out[17]=

Another classification:

In[18]:=
ResourceFunction["GetUnsplashImage"]["Object"]
Out[18]=
In[19]:=
ImageIdentify[%]
Out[19]=

Publisher

Daniel de Souza Carvalho

Version History

  • 2.0.0 – 06 April 2020
  • 1.0.0 – 03 March 2020

Author Notes

It is not guaranteed to obtain the same image running the query repetitively

License Information