zoukankan      html  css  js  c++  java
  • php imagick生成gif动画的方法

    >php imagick生成gif动画的方法
    <pre>
    <?php
    $image=new Imagick();
    $animation = new Imagick(); //建立一个对象。
    $animation->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,因为是多帧的,它会认为是多张图片
    </pre>
    ps:至于为什么在使用header设定文件头和echo 输出后图片没有动,我目前怀疑这是浏览器的设定关系,因为,你右键点击生成的图片另存下来时,图片是可以正常的跳动的。
    图片素材下载如下
    <a href="http://newmiracle.cn/wp-content/uploads/2017/04/testgifimg.zip">图片素材下载</a

  • 相关阅读:
    Test
    占位2
    开坑纪念
    function 类型(函数定义)----读书总结
    css位元素 after
    算法-哈希表
    CF547D
    CF538H
    CF516D
    CF505E
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11871349.html
Copyright © 2011-2022 走看看