21,887
社区成员
发帖
与我相关
我的任务
分享
$filelist = array('a.png', 'b.png', 'c.png', 'd.png');//组合gif动态图片的图片列表
$gif = new Imagick();
$gif->setFormat("gif");//设置生成图片的格式为gif格式
/* 添加字符串设置 ->
$str = '这是为什么呢?';//要加的字符串
$draw = new ImagickDraw;
$draw->setfont('default.ttf');//字体
$draw->setfontsize(12);//字体大小
$draw->setfillalpha(0.4);//字体透明度
$draw->arc(50, 100, 150, 150, 100, 1000);//初始化一个图形
<- */
foreach($filelist as $file){
$file = new Imagick($file);
/*
$width = $file->getimagewidth();//获取单张图片的宽
$height = $file->getimageheight();//获取单张图片的高
$file->adaptiveresizeimage($width * 3, $height * 3);//重设每张图片大小
*/
// $file->adaptiveThresholdImage(40, 10, 1);//颜色强度
// $file->adaptiveblurimage(20, 1);//模糊、锐化
// $file->resizeimage($img->getimagewidth(), $img->getimageheight(), 20, 20);//缩略、模糊
// $file->annotateImage($draw, 50, 50, 50, $str);//向图片中写字符串
// $file->drawimage($draw);//添加图形
$gif->addImage($file);//向gif图片中添加图像(图片)
$gif->setImageDelay(100);//设置间隔
}
header("Content-Type: image/gif");
//echo $gif->getImagesBlob();//直接输出就是动的
echo $gif->writeImages("test.gif", true);//如果保存就不动了
$gif->clear();
$gif->destroy();