문제

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???

도움이 되었습니까?

해결책

You should use setImageDispose method to clear the frame area:

$frame->readImage($_FILES["image$i"]);
$frame->setImageDispose(2);
$frame->setImageDelay(100);
  • Undefined: 0 -> No disposal specified (equivalent to 'none').
  • None: 1 -> Do not dispose, just overlay next frame image.
  • Background: 2 -> Clear the frame area with the background color.
  • Previous: 3 -> Clear to the image prior to this frames overlay.

And you could add a call to 'optimizeImageLayers' to reduce the size of your file:

$GIF->optimizeImageLayers();
$GIF->writeImages("C:\wamp\www\latest\im\allimage.gif" , true);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top