사이트 내 전체검색
PHP
#php Imagick animation gif 줄이기 / 프레임 특정 프레임만 출력하기
프리이미지
https://cmd.kr/php/891 URL이 복사되었습니다.

본문

<?

    /*** 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>";

 

 

?>​ 

댓글목록

등록된 댓글이 없습니다.

PHP
871 (2/18P)

Search

Copyright © Cmd 명령어 18.119.120.59