I
I
im_dimas2019-06-20 18:16:27
PHP
im_dimas, 2019-06-20 18:16:27

Where can I find an example of overlaying text on an imagick gif in php?

Good afternoon, where can I find an example of overlaying text on all GIF frames and outputting the result to the browser?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
im_dimas, 2019-06-22
@dimas199862

$project = $_GET['name'];
$bonus = $_GET['bonus'];
$id = $_GET['id'];
$type = $_GET['type'];
$anim = new Imagick(); 
$auxIMG = new Imagick();

$auxIMG->readImage('https://site.ru/images/'.$type.'.gif'); 
 

$draw1 = new ImagickDraw();
$draw2 = new ImagickDraw();
$pixel = new ImagickPixel( 'transparent' );

/* Новое изображение */
$auxIMG->newImage(800, 75, $pixel);

/* Черный текст */
$draw1->setFillColor('white');
$draw1->setTextAlignment(\Imagick::ALIGN_CENTER);
$draw1->setFontSize( 12 );
//$draw1->setFont('Bookman-DemiItalic');

$draw2->setFillColor('white');
$draw2->setTextAlignment(\Imagick::ALIGN_CENTER);
$draw2->setFontSize( 12 );
//$draw2->setFont('Bookman-DemiItalic');

foreach ($auxIMG as $frame) {
  $frame->annotateImage($draw1,87, 260, 0, $project);
  $frame->annotateImage($draw2,87, 291, 0, $bonus);
}
$anim->addImage($auxIMG); 

$name = "project".$id.".gif";
$anim->writeImages($name, true);

header("Content-Type: image/gif");
echo file_get_contents($name);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question