verycleanteeth Posted November 16, 2008 Share Posted November 16, 2008 I've got the following code which is intended to create a thumbnail of an uploaded image. I'm getting an image of the the appropriate size, and it's saving it properly, but the images are nothing but black. if ($extension == 'gif') $src_img = imagecreatefromgif("$image_path/$image_name"); else $src_img = imagecreatefromjpeg("$image_path/$image_name"); if ($img_width > $thumb_width) $new_w = $thumb_width; else $new_w = $img_width; $image_name = str_replace('.gif', '.jpeg', $image_name); $diff=$img_width/$new_w; $new_h=$new_w; if ($extension == 'gif') $dst_img = imagecreate($new_w,$new_h); else $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); if ($extension == 'gif') imagegif($dst_img, "$thumb_path/$image_name"); else imagejpeg($dst_img, "$thumb_path/$image_name"); This is my first time playing with the PHP image creation functions, so I'm sure I could be missing something very basic. Any help is appreciated! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/132904-solved-creating-thumbnails/ Share on other sites More sharing options...
verycleanteeth Posted November 16, 2008 Author Share Posted November 16, 2008 Scratch this. I'm an idiot. Quote Link to comment https://forums.phpfreaks.com/topic/132904-solved-creating-thumbnails/#findComment-691094 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.