#!/usr/bin/perl -w # create-indexes2.pl - Creating thumbnail images # for picture galleries version 2.0 (July 2002) # written by M. Verbitsky #searches directory recursively, converts all #.gif, .jpg. jpeg images to 100x100 thumbnail images $PREFIX="000thu-"; # MAIN () BEGINS HERE print " create-thumbnails goes through a directory and all its subdirectories creating 250x200 thumbnail pictures for all .gif and .jpg images \n"; my $num_args = 0; $num_args = @ARGV; if ($num_args==0) { print "\n usage: create-thumbnails3.pl [directory]\n"; exit; } @dir_list=glob("$ARGV[0]/ $ARGV[0]/*\/ $ARGV[0]/*/*\/ $ARGV[0]/*/*/*\/ $ARGV[0]/*/*/*/*\/ $ARGV[0]/*/*/*/*/*\/ $ARGV[0]/*/*/*/*/*/*\/ $ARGV[0]/*/*/*/*/*/*/*\/ $ARGV[0]/*/*/*/*/*/*/ */*\/"); foreach $dir (@dir_list) { #chistim za soboj @todelete=glob("$dir/$PREFIX* $dir/index*"); foreach (@todelete) { unlink || warn "having trouble deleting $_: $!"; print "deleting $_\n"; } @all_listing = glob("$dir/*"); #teper' udalyaem iz spiska imena direktorij @file_listing=(); foreach $file (@all_listing) { if ((-f $file)) { push (@file_listing,$file); # $numfiles=@file_listing; # print "new file listed: $file; file_listing is $numfiles long\n"; } } foreach $file (@file_listing) { # workaround the JMH problem # $jmh_file = $file; # if ($jmh_file =~/JMH$/) # { # $file =~ s/JMH$/JPG/; # rename ($jmh_file,$file) # || die "can't rename $jmh_file into $file"; # print "renaming $jmh_file into $file\n"; # } #pobedili JMH... $thu_file=$file; $thu_file=~ s/.*\///; #ubiraem direktorii $thu_file =$dir . "/" . $PREFIX . $thu_file; # we shall convert only .gif .jpg .jpeg files if ($file =~m/jpg$/i || $file =~m/jpeg$/i || $file =~m/gif$/i) { system ("convert -geometry 250x200 $file $thu_file") && print "cannot convert $file to $thu_file\n"; } print "converting $file to $thu_file\n"; } }