Generating thumbnail mosaics with Perl