It started with this post at Dangerous Minds showing a bunch of creepy animatronic dolls that you could buy, if you're into that sort of thing. The post links to this gallery page, listing over 300 terrifying images of these dummies.
If you look at that gallery page (but don't look too closely) you'll see that the boxes describing each model appears to be about the exact same size. Each one looks like a trading card of some sort. Hmm...
So I spent my lunch hour today figuring out how to turn that Web page into a graphic, and then how to extract each individual square into its own image. Why? Because sometimes you just gotta do stuff and not think about the consequences...
The first trick was trying to figure out how to turn the page into a big graphic. After some mucking about with the perl module WWW::Mechanize::Firefox I eventually discovered a Firefox extension that would turn a single page into a big graphic. I ended up with a PNG graphic 62 megabytes in size, with a dimension of 1,409 by 42,751.
Now with this graphic in hand I turned to ImageMagick for figuring out how to crop out each individual image. I figured that if each box was the exact same dimensions, I should be able to use a pair of for-next loops to grab each one.
Some investigation turned up that the command-line tool "convert" has a crop command which can take a bite out of a larger image. Some quick investigation on how to do arithmetic in the Bash shell resulted in the following one-liner, which started churning out the graphics (some trial and error was needed to get the numeric values precisely right):
for row in $(seq 1 104); do for col in $(seq 1 3); do echo "row = $row, col = $col"; convert large-image.png -verbose -crop 266x391+$((20 + $col * 272))+$((969 + $row * 395)) out_$(row)_$(col).png ; done; done
This started working well, but after about row 10 the images started being a little off-set, so I ended up having to adjust the numbers for the remaining rows. You get the idea; you can try this out on your own and adjust them as necessary.
After that, I ended up with 310 images from this Web page. And what images they are!
You get the idea.
The moral of this story: you can use shell scripting to automatically generate screenshots from a random page on the Web, and terrorize your friends in the process. Hooray for computer science!