简体   繁体   中英

How to add on my image gif's watermark with php?

I try this:

$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;

but this don't working, the images is curdle.

And try this:

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);

This code does not work I do not know why it does not. We wish you a directory where there Gif htaccess can do it in gifs watermarking

This class could be your solution:
PHP Classes transparent watermark

Take a look at the link below. I have done the same thing in php. I hope that this will helps you. https://dl.dropboxusercontent.com/u/58146160/watermark%20image.rar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM