evanct Posted February 25, 2009 Share Posted February 25, 2009 function createThumbnail($path,$tn_src) { 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); } this works perfectly, it creates a 100x100 thumbnail of the image and puts it in the directory. the Little Problem is that the thumbnail it creates is a 100% black image. what's wrong here? Link to comment https://forums.phpfreaks.com/topic/146807-solved-little-problem-with-image-thumbnail-function/ Share on other sites More sharing options...
evanct Posted February 25, 2009 Author Share Posted February 25, 2009 bump? Link to comment https://forums.phpfreaks.com/topic/146807-solved-little-problem-with-image-thumbnail-function/#findComment-771346 Share on other sites More sharing options...
evanct Posted February 25, 2009 Author Share Posted February 25, 2009 I set error_reporting to display warnings, and I get this: "Warning: imagecopyresampled(): supplied argument is not a valid Image resource". I split up the parameters of imagecopyresampled() so each was on its own line, and it pointed to $height. Link to comment https://forums.phpfreaks.com/topic/146807-solved-little-problem-with-image-thumbnail-function/#findComment-771359 Share on other sites More sharing options...
evanct Posted February 25, 2009 Author Share Posted February 25, 2009 Nevermind, it works now. not sure exactly why. Link to comment https://forums.phpfreaks.com/topic/146807-solved-little-problem-with-image-thumbnail-function/#findComment-771384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.