ImageFerret

(I no longer use ImageFerret on this site, but here's the old documentation.)

About

ImageFerret is a program I wrote in Perl to randomly grab images from the web and stick them in the upper-left corner of my web page. I needed something to go up in that corner, because otherwise it would be a boring and sterile void of darkness. The image manipulation was very easy to do, thanks to ImageMagick. Finding relevant images was also easy, thanks to Google Image Search.

How It Works

First, it randomly selects a search term using the relevant information in the configuration file. Then, it makes two queries to Google Image Search (GIS) to get a list of 20 random images related to that term. GIS provides the dimensions of each image (but not the image itself), and ImageFerret uses this information along with the specifications in the config file to weed out unsuitable images. From what images remain, ImageFerret randomly tries to download each one until it is successful or until it runs out. If it runs out of images, it queries GIS for another list of 20 images. Once it has downloaded a valid image, it then tailors it to the target size and applies a mask, if one has been specified.

I use crontab to schedule when it runs. I currently have it set to run at midnight, central time.

Config

Below is the configuration file I am currently running with ImageFerret. The target width and height, along with the mins and maxs, guide it in choosing a base image and in tailoring it to size. "always_freq" is the propability that it will choose a search term from the "always" list, instead of from the current month's list.
[settings]
target_width		150
target_height		150
min_width		120
min_height		120
max_width		0
max_height		0
max_crop		0.25
freq_month		0.5
freq_wisdom		0.0
allow_repeats		0
archive_count		10
base_search_url		http://images.google.com/images?hl=en
hit_warn_level		100
data_path		./
web_path		/atox/imageferret/
archive_template	archive_template.html
archive_extension	.html
template_file		menu_template.html if_menu.html
mask                    if_mask.png
mask_compose            Multiply

[always]
life
death
happy
sad
time
space
heaven
hell
order
chaos
good
evil
awake
asleep
strong
weak
money
normal
bizarre
strange
crazy
creepy
awesome
fear
counter strike
world of warcraft
quake
doom 3
beer
pinup
clemson
south carolina
maine
paradise
webcam
ferret
socks
homestar runner
digital blasphemy
illusion
beauty
alien
monster
music
photoshopped
pose
cuisine
lights
people
photo
screenshot
wallpaper
art
painting
movie poster
portrait
picasso
monet
mosaic
playing cards
asdf
dsc
/dsc

[jan]
january
winter
snow
cold
new years
resolution

[feb]
february
winter
snow
cold
groundhog
valentine

[mar]
march
spring
spring break
rain
vacation
shamrock
green beer

[apr]
april
spring
showers
easter
easter egg
taxes
birthday
cake

[may]
may
spring
cinco de mayo
mom
exams

[jun]
june
summer
bikini
dad
beach

[jul]
july
summer
4th of july
independence day
bbq
beach
hot sun
shades

[aug]
august
summer
lemonade
sunbathe
swimsuit
hot
sun
sunglasses

[sep]
september
autumn
foliage
school
labor day

[oct]
october
autumn
halloween
pumpkin
costume
trick or treat
oktoberfest

[nov]
november
autumn
thanksgiving
turkey
veteran

[dec]
december
winter
snow
christmas
xmas
santa
presents
christmas tree
festivus
hanukkah