This works fine for none animated images:
$image = new Imagick($file);
$format = strtolower($image->getImageFormat());
$watermark = new Imagick('watermark.png');
$watermark->scaleImage($image->getImageWidth(), $watermark->getImageHeight());
$image->addImage($watermark);
$image->resetIterator();
$combined = $image->appendImages(true);
$data = base64_encode($combined->getImageBlob());
echo '<img src="data:image/' . $format . ';base64,' . $data . '">';
How can I make this work for animated gifs? It just puts every frame below each other and the watermark below that.
See below URL i am very sure it is very help full to you:-
Watermark on animated gif with php
Try this
$animation = ani.gif;
$watermark = logo.png;
$watermarked_animation = "morph.gif";
$cmd = " $animation -coalesce -gravity South ".
" -geometry +0+0 null: $watermark -layers composite -layers optimize ";
exec("convert $cmd $watermarked_animation ");
See also
http://www.imagemagick.org/Usage/anim_mods/#composite
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=21730
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.