BarneyJoe Posted December 14, 2006 Share Posted December 14, 2006 Have been using GD library, and have noticed one particular image that for some unfathomable reason doesn't want to stick to the max and min dimensions in the script I'm using.If you look here, the image on the right is too big still :[url=http://www.oriental-chamber.co.uk/round.php]link[/url]The surrounding boxes are defined by the CSS :.hloop {border:1px solid #3B1312; padding:1px;vertical-align:top; width:170px; height:210px;}.hloop img {margin-bottom:7px;}The code generating the thumbnail images is :[code]<a href="details.php?CarpetID=<?php echo $row_chineseDesigns['CarpetID']; ?>"><img src="thumb.php?file=Photos/<?php echo $row_chineseDesigns['Image'];?>" border="0"></a>[/code]Where thumb.php sets the max and min dimensions of the image :[code=php:0]<?php // Max Sizes $th_max_width = 140; // Maximum width of the thumbnail $th_max_height = 180; // Maximum height of the thumbnail //------------------- // File $filename = $_GET['file']; // Get image sizes, type & mime $img_data = getimagesize($filename); $width = $img_data[0]; $height = $img_data[1]; $img_type = $img_data[2]; // Numeric value (check in manual) $mime = $img_data['mime']; // Content type header('Content-type: ' . $mime); // Resize $ratio = ($width > $height) ? $th_max_width/$width : $th_max_height/ $height; $newwidth = round($width * $ratio); $newheight = round($height * $ratio); // Load $thumb = imagecreatetruecolor($newwidth, $newheight); switch ($img_type){ case 1: $source = imagecreatefromgif($filename); break; case 2: $source = imagecreatefromjpeg($filename); break; // Other file types... } //Resize imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb); ?> <?php exit; ?> [/code]So the box is set to 170x210 in the CSS, and the max dimensions set in the thumb.php is 140x180.If you look at the links on the left for the other styles, everything else is just as it should be, but on this page that one image on the right insists on breaking that max height and width.As is so often the way there always has to be something to drive me nuts - any ideas what's causing this?Cheers,Iain Link to comment https://forums.phpfreaks.com/topic/30672-resolved-gd-image-library-one-single-odd-image/ Share on other sites More sharing options...
fizix Posted December 14, 2006 Share Posted December 14, 2006 That link didn't work. :-\ Link to comment https://forums.phpfreaks.com/topic/30672-resolved-gd-image-library-one-single-odd-image/#findComment-141319 Share on other sites More sharing options...
BarneyJoe Posted December 14, 2006 Author Share Posted December 14, 2006 D'oh! Should be working now. Link to comment https://forums.phpfreaks.com/topic/30672-resolved-gd-image-library-one-single-odd-image/#findComment-141332 Share on other sites More sharing options...
BarneyJoe Posted December 15, 2006 Author Share Posted December 15, 2006 Found a solution - changing the resize code to :[code=php:0]$ratio = min($th_max_width/$width, $th_max_height/$height);$newwidth = round($width * $ratio);$newheight = round($height * $ratio);[/code] Link to comment https://forums.phpfreaks.com/topic/30672-resolved-gd-image-library-one-single-odd-image/#findComment-141480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.