Public domain biological image search

Here’s a quick hack for OS X users to search EoL for public domain images. To search e.g. for beetles (EoL page ID 345) run the command something like
./ 345

#!/usr/bin/perl -w
use File::Temp qw(tempfile);
use LWP::Simple;
use JSON -support_by_pp;
use Try::Tiny;

sub open_in_browser {
system("open " . shift); # this is Mac OS X specific - modify the call for use on windows or unix
## Default settings ##
my $APIkey="0e8786f5d94e9587e31ed0f7703c9a81f3036c7f"; #replace with your own API key.
my $pagebase = ""; #see
my %page_params = (
images=> 75,
subjects=> '',
licenses=> 'pd',
key => $APIkey,
cache_ttl => "100"
my $vernacularLANG = 'en';
$vernacularLANG = $main::language if(defined($main::language));

my $id = $ARGV[0];
$id =~ s/\D//g;

my $url = $pagebase.$id.".json?".join("&", map{"$_=$page_params{$_}"} keys %page_params);
my ($fh, $filename) = tempfile(SUFFIX => ".html");
while (not($pg = fetch_json_page($url))) {
last if (++$i==3); #try getting the page a few times
sleep(1); #wait a bit and try again
print $fh "<html><head><title>EoL page_id $id: associated objects</title><style type='text/css'>img {border:1px solid black; margin: 0.2em}</style></head><body>";
unless ($pg) {
print $fh "Error in getting json page result from EoL for object id $id, tried $i times";
} else {
if (!($pg->{dataObjects}) || 0==@{$pg->{dataObjects}}) {
print $fh "(no appropriate data objects found in EoL for dataObject $id at ".$url."\n";
} else {
my $vernacular="";
if (@{$pg->{vernacularNames}}) {
foreach my $vn (@{$pg->{vernacularNames}}) {
if ($vn->{language} eq $vernacularLANG) {
if (!$vernacular || ($vn->{eol_preferred} && $vn->{eol_preferred} eq 'true')) {
$vernacular = $vn->{vernacularName}; #pick the first one

print $fh "<h2>Images listed with licence = '$page_params{licenses}' for <a href=''>EoL</a> page $id, $pg->{scientificName} ($vernacular)</h2>";
foreach my $obj (@{$pg->{dataObjects}}) {
if (($obj->{eolThumbnailURL}) && ($obj->{dataObjectVersionID})) {
print $fh "<a target='EoLsubpage' href='$obj->{dataObjectVersionID}/'><img src='$obj->{eolThumbnailURL}'></a>";
print $fh "<p>Page acccessed was: <blockquote style='word-break:break-all;'>$url</blockquote></p></body></html>";

sub fetch_json_page
my $json = new JSON;
my ($json_url) = shift;
# download the json page:
my $json_text;
my $content = get( $json_url );
try {
# these are some nice json options to relax restrictions a bit:
} catch {
warn "Caught JSON error: $_\n";
return $json_text;

One thought on “Public domain biological image search

  1. Pingback: Finding public domain images of lifeforms | A Scientific View

Leave a Reply

Your email address will not be published. Required fields are marked *