这适用于没有动画的图像:
$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 . '">';
我怎样才能为GIF动画制作这个作品? 它只是将每一帧都放在彼此之下,并将水印放在下面。
答案 0 :(得分:0)
请参阅以下网址我非常确定这对您非常满意: -
Watermark on animated gif with php
试试这个
$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 ");
另见
http://www.imagemagick.org/Usage/anim_mods/#composite
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=21730