[英]Watermark to animated GIF with PHP ImageMagick library
I have added PHP watermark animated image but i have faced problem the orginal.gif
image is not animated after creating the watermark. 我添加了PHP水印动画图像,但是我遇到了问题:创建水印后
orginal.gif
图像没有动画。
Code: 码:
<?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 orginal.gif
watermark.png watermark.png
Output: 输出:
Description: I have a form there is option to upload file, Upload file only accept gif image after upload the gif image the gif image will show with the logo watermark in the site. 说明:我有一个表单,可以选择上传文件,上传文件仅接受gif图像,上传gif图像后gif图像将在站点中显示带有徽标水印。 But when give watermark image the watermark GIF image is not animated.
但是,当给水印图像时,水印GIF图像不会动画。
you can try this : 你可以试试这个:
//use imagemagick command-line
passthru("convert -coalesce orginal.gif -gravity SouthEast -draw 'Image Over 10,10,0,0 $watermark.png' Output.gif");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.