Reputation: 3414
I have added PHP watermark animated image but i have faced problem the orginal.gif
image is not animated after creating the watermark.
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
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. But when give watermark image the watermark GIF image is not animated.
Upvotes: 2
Views: 1453
Reputation: 76
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");
Upvotes: 1