If width larger, resize x or if height larger resize y

See all posts Reply

If width larger, resize x or if height larger resize y new!
by Ahmet Kemal, 14 years, 3 months ago
Hello guys,

As you know, some pictures are so long and some are so wide. What I want is resizing image based on X if it is too wide. If it is not a wide picture but very long one, resizing it based on Y.

Any suggestions appreciated.Reply
Re: If width larger, resize x or if height larger resize y new!
by colin, 14 years, 3 months ago
You can read image_src_x and image_src_y before calling process(), and act accordingly. For instance:
if ( $handle->image_src_x > 1000 ) {
    $handle->image_x = 1000;
    $handle->image_ratio_y = true;
} else {
    $handle->image_y = 300;
    $handle->image_ratio_x = true;
}  
$handle->process(...);
Reply
Re: If width larger, resize x or if height larger resize y new!
by Darteye, 11 years, 5 months ago
ten przykład też się przyda thx ...ale jest problem
a wiesz jak wyliczyć stosunek proporcji?
zdjęcie może być 3500x2300 i nie jest panorama
lub 4500x1080 i wtedy jestReply
Re: If width larger, resize x or if height larger resize y new!
by Darteye, 11 years, 5 months ago
This example also be useful thx ... but the problem is
and you know how to calculate the ratio of proportion?
Stock Image can be 3500x2300, and is not panorama
or 4500x1080 and then it isReply
Re: If width larger, resize x or if height larger resize y new!
by Darteye, 11 years, 5 months ago
sorry

I gave: $ handle-> image_y
instead of: $ handle-> image_ratio_y

Now everything is working! BIG thanks a lot! ;)Reply
Re: If width larger, resize x or if height larger resize y new!
by Ahmet Kemal, 14 years, 3 months ago
Hi Colin,

Thank you for your inspiration. What I want was not what you told but I learned how to get original image sizes thanks to your post. What I actually want is:
if ( $handle->image_src_y > $handle->image_src_x ) {
  $handle->image_ratio_x = true;
  $handle->image_y = 80;
} else {
  $handle->image_ratio_y = true;
  $handle->image_x = 80;
}

Thanks again,Reply