【问题标题】:How to add on my image gif's watermark with php?如何用 php 在我的图像 gif 上添加水印?
【发布时间】:2013-08-15 05:01:04
【问题描述】:

我试试这个:

$path = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
$image = imagecreatefromstring(file_get_contents($path));

$w = imagesx($image);
$h = imagesy($image);

$centerX=round($w/4);
$centerY=round($h/2);

$watermark = imagecreatefrompng('lool-face.png');
$ww = imagesx($watermark);
$wh = imagesy($watermark);

imagecopy($image, $watermark, $centerX, $centerY, 0, 0, $ww, $wh);

eregi('\.(gif|jpeg|jpg|png)$',$path,$regs);
switch( $regs[1] ) {
case 'gif':
   header('Content-type: image/gif');
   imagegif($image);
   break;

但这不起作用,图像是凝固的。

试试这个:

shell_exec('for i in sphere*.gif; do convert $i  -font Arial -pointsize 20 \
    -draw "gravity south \
    fill black  text 0,12 \'Copyright\' \
    fill white  text 1,11 \'Copyright\' " \
    wmark_$i; done');

shell_exec("convert   -delay 20   -loop 0   wmark_sphere*.gif   animatespheres.gif");
$f = fopen("animatespheres.gif", 'rb');
fpassthru($f);
fclose($f);

这段代码不起作用我不知道为什么它不起作用。 我们希望你有一个目录,那里有 Gif htaccess 可以在 gifs 水印中做到这一点

【问题讨论】:

    标签: php image gif watermark shell-exec


    【解决方案1】:

    此类可能是您的解决方案:
    PHP Classes transparent watermark

    【讨论】:

    • 我记得我曾尝试过动画 GIF 叠加,但我花了很长时间,因为动画中断了
    【解决方案2】:

    看看下面的链接。我在php中做了同样的事情。我希望这会对你有所帮助。 https://dl.dropboxusercontent.com/u/58146160/watermark%20image.rar

    【讨论】:

    • 要使其与 gif 一起使用,您必须稍微更改 funs.php 中的代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 2011-05-03
    • 1970-01-01
    相关资源
    最近更新 更多