简体   繁体   English

图像Magick动画图像

[英]Image Magick animating images

Hello people here is my code below... 大家好,这是我的以下代码...

        $_FILES=array();
        $GIF = new Imagick();
        $GIF->setFormat("gif");

        $_FILES['image0']="C:\wamp\www\latest\im\image0.gif";
        $_FILES['image1']="C:\wamp\www\latest\im\image1.gif";
        $_FILES['image2']="C:\wamp\www\latest\im\image2.gif";
        $_FILES['image3']="C:\wamp\www\latest\im\image3.gif";



        for ($i = 0; $i < sizeof($_FILES); ++$i) {


            $frame = new Imagick();
            $frame->readImage($_FILES["image$i"]);
            $frame->setImageDelay(100);
            $GIF->addImage($frame);
        }

        $GIF->writeImages("C:\wamp\www\latest\im\allimage.gif" , true);

above code works fine by creating an Animated gif, But the problem is it overlaps on the previous images,,,Iam trying to disappear the previous image when the next image comes... something like Timer ,... is there a way to fix this??? 上面的代码通过创建Animated gif可以很好地工作,但是问题是它与前一张图像重叠,我试图在下一张图像出现时disappear the previous image一张图像...类似Timer ,...解决这个问题???

You should use setImageDispose method to clear the frame area: 您应该使用setImageDispose方法清除框架区域:

$frame->readImage($_FILES["image$i"]);
$frame->setImageDispose(2);
$frame->setImageDelay(100);
  • Undefined: 0 -> No disposal specified (equivalent to 'none'). 未定义:0->未指定处理方式(等同于“无”)。
  • None: 1 -> Do not dispose, just overlay next frame image. 无:1->不丢弃,仅覆盖下一帧图像。
  • Background: 2 -> Clear the frame area with the background color. 背景:2->用背景色清除边框区域。
  • Previous: 3 -> Clear to the image prior to this frames overlay. 上一页:3->在此帧覆盖之前清除图像。

And you could add a call to ' optimizeImageLayers ' to reduce the size of your file: 您可以添加对“ optimizeImageLayers ”的调用以减小文件的大小:

$GIF->optimizeImageLayers();
$GIF->writeImages("C:\wamp\www\latest\im\allimage.gif" , true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM