Create gif with countdown

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
werixon
Posts: 2
Joined: 2019-02-12T07:28:41-07:00
Authentication code: 1152

Create gif with countdown

Post by werixon »

Hi everybody,
please, can you help me with creating gif image in Imagick with countdown in PHP? I need to countdown one second every second :-D so a need create one frame every second. Thank you werixon
werixon
Posts: 2
Joined: 2019-02-12T07:28:41-07:00
Authentication code: 1152

Re: Create gif with countdown

Post by werixon »

Hi, so I have this code. Now I try to create 120 frames for 120 and open at the browser. But a got error - empty screen.

Code: Select all

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

$draw = new ImagickDraw();
$draw->setFillColor('black');
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 30 );

for ($i = 0; $i <= 120; ++$i) {
    $frame = new Imagick();
    $frame->newImage(100, 100, new ImagickPixel("red"));
    $frame->setImageDelay(10);
    $frame->annotateImage($draw, 10, 45, 0, $i);

    $GIF->addImage($frame);
}

header('Content-type: image/gif');
echo $GIF->getImagesBlob();
Post Reply