Patrick Horgan and I wrote a program (actually a long shell script)
that does exactly what you want, but it only works on Linux and Mac
so far. Depending on your computer skills, you might be able to make
it work on Windows using Cygwin--I've experimented a bit with this
but I'm terrible on Windows and don't have the time to fiddle with
it. I'm attaching the script for you in case you want to try it
out. The main dependency is the netbpm suite of image manipulation
tools, which is available freely for Windows.

Alternatively you could make a Linux partition or a Wubi Linux
installation on your XP machine and run the program while booted
into Linux. Best of luck :)