Hi i wrote a code for image upload and watermarking. It is working fine in Jpg but not in gif.... The code is
$ext = end(explode('.', $final_file));
if($ext == 'jpg'){
$ext_new = 'jpeg';
} elseif ($ext == 'JPG' || $ext == 'JPEG'){
$ext_new = 'jpeg';
}else {
$ext_new = $ext;
}
$po="imagecreatefrom".$ext_new;
//////////////////Resize///////////////
$finalfilename="share/".$final_file;
$src = $po($finalfilename);
list($width,$height)=getimagesize($finalfilename);
$newwidth=200;
$newheight=200;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = "share/".$final_file;
imagejpg($tmp,$filename,100);
imagedestroy($src);
//unlink($final_file);
imagedestroy($tmp);
////////////////watermark///////////////////////////
$orgimage=$po($finalfilename); // your image
$watermark=imagecreatefrompng("logo.png"); //transparent watermark logo
// $watermark=imagecreatefromgif("yourlogo.gif");
imagecopy($orgimage,$watermark,0,0,0,0,imagesx($watermark),imagesy($watermark));
imagejpeg($orgimage,$filename,100);
imagedestroy($watermark);
imagedestroy($orgimage);
The following error :
Warning: imagecreatefromgif() [function.imagecreatefromgif]: 'share/-yyyy-.gif' is not a valid GIF file in C:\wamp\www\water\process.php on line 98
Warning: imagecopy(): supplied argument is not a valid Image resource in C:\wamp\www\water\process.php on line 101
Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\wamp\www\water\process.php on line 103
Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\water\process.php on line 105
Please help me with the correction