#!/usr/bin/perl # # Generate a series of thumbnails for all *.jpg files in the # current directory. # # Public domain # $THUMB_SIZE = '120x120'; $THUMB_EXT = '.small.jpg'; $COLS = 4; my $ncol = 0; print ''; opendir(DIR, '.') || die ".: $!"; foreach my $file (readdir(DIR)) { if ($file =~ /^\./ || $file =~ /$THUMB_EXT$/ || $file !~ /^([\w\s\-\.]+)\.jpg$/) { next; } my $thumb = $1.$THUMB_EXT; unless (-e $thumb) { print STDERR "$file -> $thumb\n"; system("nice -n 20 convert '${file}' -resize $THUMB_SIZE ". "'$thumb'"); if ($? != 0) { print STDERR "convert failed\n"; exit(1); } } print << "EOF"; EOF if (++$ncol == $COLS) { print ''; $ncol = 0; } } closedir(DIR); print '
${file}
';