【问题标题】:Watermark to animated GIF with PHP ImageMagick library使用 PHP ImageMagick 库为动画 GIF 加水印
【发布时间】: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图像不是动画的。

【问题讨论】:

标签: php image animation animated-gif watermark


【解决方案1】:

你可以试试这个:

//use imagemagick command-line
passthru("convert -coalesce orginal.gif -gravity SouthEast -draw 'Image Over 10,10,0,0    $watermark.png' Output.gif");

【讨论】:

    猜你喜欢
    • 2016-12-14
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多