spdwrench Posted September 20, 2007 Share Posted September 20, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/70054-solved-problem-when-image-sizes-are-not-rectangles/ Share on other sites More sharing options...
spdwrench Posted September 20, 2007 Author Share Posted September 20, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/70054-solved-problem-when-image-sizes-are-not-rectangles/#findComment-351821 Share on other sites More sharing options...
cooldude832 Posted September 20, 2007 Share Posted September 20, 2007 Images can't be defined in objects other than rectangles, reguardless if the image is a circular shape, the physical container is and always will be a rectangle Quote Link to comment https://forums.phpfreaks.com/topic/70054-solved-problem-when-image-sizes-are-not-rectangles/#findComment-351824 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.