//利用远程gif图片创建新gif图片
function resizegif($imgsrc,$imgwidth,$imgheight,$filepath)
{
$arr = getimagesize($imgsrc);
$imgWidth = $imgwidth;
$imgHeight = $imgheight;
$imgsrc = imagecreatefromgif($imgsrc);
$image = imagecreatetruecolor($imgWidth, $imgHeight); //创建一个彩色的底图
imagecopyresampled($image, $imgsrc, 0, 0, 0, 0,$imgWidth,$imgHeight,$arr[0], $arr[1]);
if(file_exists($filepath)){
unlink($filepath);
imagegif($image,$filepath);
}else{
imagegif($image,$filepath);
}
function resizegif($imgsrc,$imgwidth,$imgheight,$filepath)
{
$arr = getimagesize($imgsrc);
$imgWidth = $imgwidth;
$imgHeight = $imgheight;
$imgsrc = imagecreatefromgif($imgsrc);
$image = imagecreatetruecolor($imgWidth, $imgHeight); //创建一个彩色的底图
imagecopyresampled($image, $imgsrc, 0, 0, 0, 0,$imgWidth,$imgHeight,$arr[0], $arr[1]);
if(file_exists($filepath)){
unlink($filepath);
imagegif($image,$filepath);
}else{
imagegif($image,$filepath);
}
}
$imgsrc="http://domain/2.gif";
$filepath = "/a/1.gif";
resizegif($imgsrc,100,50,$filepath);
exit;