evanct Posted February 27, 2009 Share Posted February 27, 2009 I posted this the other day but the issue resolved itself somehow. Now it's back again - even though I didn't even change the script! It's confusing. The problem is the image that's created is completely black. It's the correct dimensions and it's placed in the correct directory, but it's just a black square. Here's the troublemaker: function createThumbnail($path,$tn_src,$thumb_size) { require('config.php'); $size = getimagesize($path); $width = $size[0]; $height = $size[1]; if($width> $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height> $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_im = ImageCreatetruecolor($thumb_size,$thumb_size); $im = imagecreatefromjpeg($path); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height); imagejpeg($new_im,$tn_src,100); } If there's something wrong I don't see it. do you? Link to comment https://forums.phpfreaks.com/topic/147230-solved-problem-with-image-thumbnail-function/ Share on other sites More sharing options...
evanct Posted February 27, 2009 Author Share Posted February 27, 2009 oh it was only happening with pngs because I was only using imagecreatefromjpeg. whoops. TOPIC SOLVED Link to comment https://forums.phpfreaks.com/topic/147230-solved-problem-with-image-thumbnail-function/#findComment-772909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.