You can definitely make such a script, just as a php page that loads each image in the gallery.
If you modify i.php, you could add a flag that makes it not load the actual image in the browser so that's faster.
Other options are to use a batch image resizing program, and use the naming scheme that ZP uses. They're named like:
[folder name]_[file name]_[size].jpg
ex: Desktop Pictures_Dog and Cat.jpg_480.jpg
Then pop them in the cache/ folder.