php imagick生成gif动画的方法

来源:互联网 发布:第章启航网络 编辑:程序博客网 时间:2024/05/16 05:43
php imagick生成gif动画的方法
setFormat( "gif" ); //设置它的类型。$delay = 30; //设置播放速度。for ($i=1; $i<52; $i++) {    $thisimage = new Imagick();    $thisimage->readImage('testgifimg/frame-'.$i.'.gif'); //我有三个图片分别叫:1.jpg,2.jpg就是要合成他们三个。    $thisimage->setFormat( "gif" ); //把他们都转成GIF格式。    $animation->addImage($thisimage); //加入到刚才建立的那个gif imagick对象之中。    $animation->setImageDelay( $delay ); //设置好播放速度。}header( "Content-Type: image/gif" );$animation->writeImages("9.gif",true); //文件存储。不能使用writeImage,因为是多帧的,它会认为是多张图片
ps:至于为什么在使用header设定文件头和echo 输出后图片没有动,我目前怀疑这是浏览器的设定关系,因为,你右键点击生成的图片另存下来时,图片是可以正常的跳动的。

查看原文:http://newmiracle.cn/?p=1408
0 0
原创粉丝点击