/home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screensho +t from 2014-08-21 13:10:18.png has filesize of 250625 bytes or 244.75 +09765625 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/S +creenshot from 2014-08-21 13:10:18.png ratio is 2.39951937806373 /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screensho +t from 2014-09-25 17:14:08.png has filesize of 166140 bytes or 162.24 +609375 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/S +creenshot from 2014-09-25 17:14:08.png ratio is 1.59064797794118 /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/Screensho +t from 2014-08-21 13:22:42.png has filesize of 81126 bytes or 79.2246 +09375 k /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/zbears.jp +g has filesize of 872877 bytes or 852.4189453125 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/z +bears.jpg ratio is 8.35704848345588 /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/. has fil +esize of bytes or 0 k /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/.. has fi +lesize of bytes or 0 k /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/yjj.jpg h +as filesize of 237182 bytes or 231.623046875 k file is /home/fred/Desktop/root3/pages/giants/template_stuff/aimages/y +jj.jpg ratio is 2.27081418504902

I'm pretty close on this one now. I know by what amount I want to reduce filesizes to. The syntax I relied on doing it bash style was a percentage. I'm still looking for that option. For what I'm doing right now, I don't want to bias the shapes of the things I post. I handle their shapes with the css. This is what I have now:

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"; } }

In reply to Re^2: Using ImageMagick effectively by Aldebaran
in thread Using ImageMagick effectively by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.