Home > Article > Backend Development > PHP gif image watermark code_PHP tutorial
The php gd library cannot add watermarks to gif images. If you want to use php to add watermarks to gif images, you have to use a PHP extension with ImageMagick function, which can help us complete the functions we want. .
PHP tutorial gd library cannot add watermarks to gif images. If you want to use php to add watermarks to gif images, you have to use a php extension with imagemagick function, which can help us complete the functions we want. oh.
$imagedraw = new imagick();
$pixel = new imagickpixel('gray');
$pixel->setcolor('black');
$imagedraw->newimage(100, 75, $pixel);
$draw = new imagickdraw();
$draw->setfont('bookman-demiitalic');
$draw->setfontsize(12);
$image=new imagick();
$animation = new imagick();
$animation->setformat( "gif" );
$image->readimage("old.gif");
$unitl = $image->getimageindex();
$image->writeimages('animation.gif',false);
$delay = $image->getimagedelay();
$filename = 'animation-';
for ($i=0; $i<$unitl; $i++) {
$thisimage = new imagick();
$thisimage->readimage($filename.$i.'.gif');
$thisimage->annotateimage($draw, 0, 12, 0, 'copyright by mpeg');
$animation->addimage($thisimage);
$animation->setimagedelay($delay);
}
header("content-type: image/gif");
echo $animation->getimagesblob();
?>
PHP extension for imagemagick functionality. Using this extension allows PHP to have the same functionality as ImageMagick. Imagemagick is a powerful, stable and free toolset and development package that can be used to read, write and process image files in more than 185 basic formats, including popular tiff, jpeg, gif, png, pdf and photocd formats. . Using imagemagick, you can dynamically generate images according to the needs of web applications. You can also change the size, rotate, sharpen, reduce color or add special effects to an image (or a group of images), and save the results in the same format. or save in other formats.
Component download address
http://pecl.php.net/package/imagick
http://www.imagemagick.org