It can be done but you should really have a small and a large copy of
each image. The small copies appear in the index page and the links in
this page reference the large copies. If you can arrange the image
files like this I can offer a PHP script that should do what you want.