#!/usr/local/bin/perl


#get list of images
#$a = `ls Elaeocarpus*chloranthus*.jpg`;
$a = `cat c`;
@aa = split (/\n/,$a);
foreach $img (@aa){
   $img =~ s/ /\\ /g;
   $img =~ s/&/\\&/g;
print "$img \n";
   $newimg = $img;
   $newimg =~ s/BIG\///;
   $thumb = $img;
   $thumb =~ s/jpg$/thumb\.jpg/;
   $thumb =~ s/^/thumbs\//;
	# identify
   $cmd = "identify $img";
print "$cmd\n";
   $_ = `$cmd`;
   $tmp = /(\d+)x(\d+)/;
   $width = $1;
   $height = $2; 

	# make thumbnails 
   $twidth = int($width * 160/$height);
   $cmd = "convert -geometry ${twidth}x160 $img $thumb ";
   print "$cmd\n";
   `$cmd`;
# 	# make image small if wider than 800pixels
#   if ($width >800){
#	$theight = int($height*800/$width);
#	$cmd = "convert -geometry 800x$theight $img $newimg ";
#   	print "$cmd\n";
#    	`$cmd`;
#   }else{
#	$cmd = "cp $img $newimg";
#   	print "$cmd\n";
#	`$cmd`;
#   }
}

