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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.