Subject: | wrong resize in some cases |
Date: | Tue, 05 Sep 2006 16:19:28 +0100 |
To: | bug-Image-Magick-Thumbnail [...] rt.cpan.org |
From: | Martin Friebe <mfriebe [...] hybyte.com> |
the divisor to resize the picture is calculated depending on the
original pictures ratio
my $r = ($ox>$oy) ? ($ox/$maxx) : ($oy/$maxy);
but:
if the new size is someting like 100x20
and the orig size is like 1000x300
then 1000 is bigger than 300, so r = 1000/100 = 10
this will lead to the new y size = 300/10 = 30
however the restriction was maxy = 20 -> bug
the fix
my $r = ($ox/$maxx) > ($oy/$maxy) ? ($ox/$maxx) : ($oy/$maxy);
out of the 2 possible divisors, take the bigger one.
(pre-calc the values into variables, to avoid double execution of the division.....)