【发布时间】:2014-02-28 13:08:44
【问题描述】:
我添加了 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图像不是动画的。
【问题讨论】:
-
@Alex 我已经检查了上面的链接,但那是一样的...无法转换图像...
标签: php image animation animated-gif watermark