프리이미지
사이트 내 전체검색

 

#php Imagick animation gif 줄이기 / 프레임 특정 프레임만 출력하기

페이지 정보

작성일17-02-11 01:25

본문

<?

    /*** Read in the animated gif ***/

    $animation = new Imagick("thumb-4016.f53e0a_30x25.gif");

 

$new_animation = new Imagick(); 

$new_animation->setFormat("gif");

 

    /*** Loop through the frames ***/

$cnt=0;

    foreach ($animation as $frame)

    {

        /*** Thumbnail each frame ***/

        $frame->thumbnailImage(100, 100);

    

        /*** Set virtual canvas size to 100x100 ***/

        $frame->setImagePage(100, 100, 0, 0);

$frame_single = $frame->getImage();

//$frame_single->setImageDelay(10);

$new_animation->addImage($frame_single);

 

if ($cnt++>10) break;

    }

 

$animation = $animation->deconstructImages();

 

$new_animation->writeImages('tmp_new.anim.gif', true); 

 

    /*** Write image to disk. Notice writeImages instead of writeImage ***/

    $animation->writeImages("thumb-1.gif", true);

    echo "Images written<BR>";

 

echo filesize("thumb-4016.f53e0a_30x25.gif"),"<BR>";;

 

echo filesize("thumb-1.gif"),"<BR>";;

echo filesize("tmp_new.anim.gif"),"<BR>";;

 

echo "<img src=thumb-4016.f53e0a_30x25.gif><BR>";

echo "<img src=thumb-1.gif><BR>";

echo "<img src=tmp_new.anim.gif><BR>";

 

 

?>​ 

추천 0
Total 799건 1 페이지
게시물 검색