Page 1 of 1

Create gif with countdown

Posted: 2019-02-12T07:32:51-07:00
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

Re: Create gif with countdown

Posted: 2019-02-12T08:08:15-07:00
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();