/home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screenshot from 2014-08-21 13:10:18.png has filesize of 250625 bytes or 244.7509765625 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screenshot from 2014-08-21 13:10:18.png ratio is 2.39951937806373 /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screenshot from 2014-09-25 17:14:08.png has filesize of 166140 bytes or 162.24609375 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screenshot from 2014-09-25 17:14:08.png ratio is 1.59064797794118 /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screenshot from 2014-08-21 13:22:42.png has filesize of 81126 bytes or 79.224609375 k /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/zbears.jpg has filesize of 872877 bytes or 852.4189453125 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/zbears.jpg ratio is 8.35704848345588 /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/. has filesize of bytes or 0 k /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/.. has filesize of bytes or 0 k /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/yjj.jpg has filesize of 237182 bytes or 231.623046875 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/yjj.jpg ratio is 2.27081418504902 #### sub resize_images { use 5.010; use Path::Class; use Image::Magick; my ($rvars) = shift; my %vars = %$rvars; $target = 100; $bias = 2; opendir my $hh, $vars{to_images} or warn "warn $!\n"; while (defined ($_ = readdir($hh))){ my $image = Image::Magick->new; my $file = file($vars{to_images},$_); $image->ReadImage($file); $x = $image->Get('filesize'); my $k = $x/1024; say "$file has filesize of $x bytes or $k k"; if ($k>$target){ say "file is $file"; my $ratio = $k/($target+$bias); say "ratio is $ratio"; } }