sub MakeThumb {
my $src = Image::Magick->new;
$src->Read("$impath/$file");
#grab size
my ($width, $height) = $src->Get('width', 'height');
#reduce size
$width = $width/$div;
$height = $height/$div;
# Create the thumbnail based on reduced size
my ($thumb,$x,$y) = create($src,$width,$height);
# Save thumbnail to file(CH this works)
$thumb->Write("$file");
print qq~
~;
#get rid of temp file
unlink ("$file") or die "can't unlink $file!\n";
}