resize thumbnail to correct size (logic)
Posted: Sat May 14, 2005 9:36 pm
Heh, this is bugging me.
Original was 1024 x 768.
Thumb ended up being 200 x 112.
Obviously not the same ratio...
I need it to shrink so that the height is <= 150 and the width is <= 200.
Anyone want to have a go at fixing this?
Original was 1024 x 768.
Thumb ended up being 200 x 112.
Obviously not the same ratio...
Code: Select all
$new_h = 150;
$new_w = 200;
$old_x = imageSX($src_img);
$old_y = imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w = $new_w;
$thumb_h = $old_y * ($new_h / $old_x);
}
elseif ($old_x < $old_y) {
$thumb_w = $old_x * ($new_w / $old_y);
$thumb_h = $new_h;
}
else {
$thumb_w = $new_w;
$thumb_h = $new_h;
}Anyone want to have a go at fixing this?