mdmartiny Posted May 2, 2011 Share Posted May 2, 2011 On the site that I am building. I have several images, some are tall images and some are wide images, I was wondering if there was a way with PHP that I can choose what demonsions are used to display the image based on image pixels? Something like if ($image = 450px ) { display width = "250" height = "150" } else { display width = "150" height = "250" } If there is away how would I go about doing any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/235360-is-this-possible/ Share on other sites More sharing options...
spiderwell Posted May 2, 2011 Share Posted May 2, 2011 you can use the gd() object for image manipulation to get the width and height, personally i would use a dynamic thumbnail script (that someone else wrote since theres plenty of them) to display the image to any size/proportion i chose. it would look something like <img src="thumbnailscript.php?file=picture.jpg&width=100&height=200"> passing the info to the php to spit out the image how you want it or use javascript to resize it client side, but of course that relies on javascript to be turned on (who even turns it off anyway I ask myself!!) Quote Link to comment https://forums.phpfreaks.com/topic/235360-is-this-possible/#findComment-1209500 Share on other sites More sharing options...
gizmola Posted May 3, 2011 Share Posted May 3, 2011 You seem to be confused about what pixels are used for. Pixels are not equivalent to "area". When you have dimensions for height and width, those dimensions are in pixels. Your pseudo code doesn't make any sense. There are several different libraries (exif, gd, imagemagick) which have routines that can be used to open most common image files and return you information including the height and width in pixels. Quote Link to comment https://forums.phpfreaks.com/topic/235360-is-this-possible/#findComment-1209791 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.