Jump to content

[SOLVED] problem when image sizes are not rectangles


spdwrench

Recommended Posts

I integrated an image resizer into my photos upload page it works great

 

it takes any image bigger than 800 * 600 and sizes it down

 

it only checks if its a long or tall image and has two different resize values..

 

this is fine if the images have not been cropped by someone for example a head cropped out of a picture would not be a rectangle image... and the new resize would distort the image...

 

how can I check if it is not rectangle and if so resize it down to the proper ratio making it smaller than 800 * 600

 

Any Ideas?

 

I really just cant do the math on this?

 

thanks for any help

 

here is the code or a bit of it

 

 if ($size[0] > $max_image_width||$size[1]>$max_image_height)
               {
$imageEditor = new ImageEditor($file_source, "photos/");
if ($size[0]>$size[1]){$imageEditor->resize(800,600);
$dtw=30;}
else {$imageEditor->resize(450,600);
$dtw=17;}
$imageEditor->outputFile($file_source, "photos/");

}

 

thanks for any help or direction on this

I found it...

 

jeez I always ask before I do a google search... here is how I fixed it

 

 if ($size[0] > $max_image_width||$size[1]>$max_image_height)
               {
$imageEditor = new ImageEditor($file_source, "photos/");
if ($size[0]>$size[1])
{
$nht = $size[1] * (800/$size[0]);
$imageEditor->resize(800,$nht);
$dtw=30;}
else {
$nwt = $size[0] * (600/$size[1]);
$imageEditor->resize($nwt,600);
$dtw=17;}
$imageEditor->outputFile($file_source, "photos/");

}

 

 

Paul

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.