Padgoi Posted July 12, 2007 Share Posted July 12, 2007 Hi, so I have this website that allows users to post images into a specific div, however the div has certain width constraints and I don't want the users to post an image that stretches this div. I want the div to automatically resize the image to fit within the width contraints of the div. I don't want to use overflow: hidden because that just hides the part of the image that doesn't fit in the div, I need it to automatically resize the image to fit into the div, kind of how a table can. Any way to do this without recoding the entire script using tables? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 www.php.net/gd GD Library. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 12, 2007 Share Posted July 12, 2007 or without GD setting image parameters <?php $image = "http://www.me.com/images/image.jpg"; $tempimg = getImageSize($image); $size = $tempimg[3]; $size = explode("\"",$size); $width = $size[1]; $height = $size[3]; while($height > 500 || $width > 500) { $width = .99*$width; $height = .99*$height; } echo "<img src=\"".$image."\" width=\"".$width."\" height=\"".$height."\" /> ?> Quote Link to comment 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.