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? Link to comment https://forums.phpfreaks.com/topic/59680-auto-fit-an-image-into-a-div-with-width-contraints-using-php/ Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 www.php.net/gd GD Library. Link to comment https://forums.phpfreaks.com/topic/59680-auto-fit-an-image-into-a-div-with-width-contraints-using-php/#findComment-296634 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."\" /> ?> Link to comment https://forums.phpfreaks.com/topic/59680-auto-fit-an-image-into-a-div-with-width-contraints-using-php/#findComment-296665 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.