GD GIF
Posted: Mon Nov 21, 2005 9:42 am
im trying to create a thumb of a GIF image. currently this function produces a blank, black image
i called the function with this
the file that is being uploaded is a gif, so there was no need for checks to make sure its gif
Code: Select all
function createthumb($name,$filename,$new_w,$new_h){
global $gd2;
$system=explode(".",$name);
$src_img=imagecreatefromgif($name);
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=imagecreatetruecolor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
imagegif($dst_img,$filename);
imagedestroy($dst_img);
imagedestroy($src_img);Code: Select all
createthumb($dir.$_FILES['filetoupload']['name'],$dir."thumbs/".$_FILES['filetoupload']['name'],100,100);