我添加了PHP水印动画图片,但我遇到了问题,orginal.gif
图片在创建水印后没有动画。
代码:
<?php
$image = new Imagick();
$image->readImage("orginal.gif");
$watermark = new Imagick();
$watermark->readImage("watermark.png");
// how big are the images?
$iWidth = $image->getImageWidth();
$iHeight = $image->getImageHeight();
$wWidth = $watermark->getImageWidth();
$wHeight = $watermark->getImageHeight();
if ($iHeight < $wHeight || $iWidth < $wWidth) {
// resize the watermark
$watermark->scaleImage($iWidth, $iHeight);
// get new size
$wWidth = $watermark->getImageWidth();
$wHeight = $watermark->getImageHeight();
}
// calculate the position
$x = ($iWidth - $wWidth) / 2;
$y = ($iHeight - $wHeight) / 2;
$image->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
header("Content-Type: image/" . $image->getImageFormat());
echo $image;
?>
orginal.gif
watermark.png
输出:
说明:我有一个表单,有上传文件的选项,上传文件只接受gif图片上传gif图片后,gif图片会显示网站上的徽标水印。但是当给出水印图像时,水印GIF图像不是动画的。
答案 0 :(得分:0)
你可以试试这个:
//use imagemagick command-line
passthru("convert -coalesce orginal.gif -gravity SouthEast -draw 'Image Over 10,10,0,0 $watermark.png' Output.gif");