zander1983 Posted January 24, 2012 Share Posted January 24, 2012 Hi Im working on a market place style website. the framework im using is called elgg. it uses an algoritm to find the right approximate width and height of an image thats being uploaded. but on my site, all heights and widths must be the same. this is difficult because some pictures have much greater width than height and some have much greater height. so whats the best algoritm to use to make an accurate thumbnail of all images uploaded? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/255644-algorithm-for-uploading-images-so-they-all-have-exact-same-width-and-height/ Share on other sites More sharing options...
joel24 Posted January 24, 2012 Share Posted January 24, 2012 //have a static width and find the percentage of that in terms of the original width, then times it by the original height $width = $imageWidth; $height = $imageHeight; $newWidth = 300; $newHeight = $newWidth / $width * $height; Quote Link to comment https://forums.phpfreaks.com/topic/255644-algorithm-for-uploading-images-so-they-all-have-exact-same-width-and-height/#findComment-1310507 Share on other sites More sharing options...
zander1983 Posted January 24, 2012 Author Share Posted January 24, 2012 but this will give diffrerent new height for each image. i need it like etsy.com where every image has same width and height... Quote Link to comment https://forums.phpfreaks.com/topic/255644-algorithm-for-uploading-images-so-they-all-have-exact-same-width-and-height/#findComment-1310508 Share on other sites More sharing options...
joel24 Posted January 24, 2012 Share Posted January 24, 2012 you'll need to crop the image using imagecopy()... scroll down on that page and the example show code which will crop Quote Link to comment https://forums.phpfreaks.com/topic/255644-algorithm-for-uploading-images-so-they-all-have-exact-same-width-and-height/#findComment-1310511 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.