Php GIF Image Watermarking code

Source: Internet
Author: User
Tags imagemagick

The php gd library cannot add watermarks to gif images. If you want to use php to add watermarks to gif images, you must use a PHP extension of the ImageMagick function, it can help us complete the functions we want.

The gd library in the php tutorial cannot add watermarks to gif images. If you want to use php to add watermarks to gif images, you must use a php extension of the imagemagick function, it can help us complete the functions we want.

<? Php
$ 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.ii.'.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 of imagemagick function. With this extension, php can have the same functions as imagemagick. Imagemagick is a powerful, stable, and free toolkit that can be used to read, write, and process image files in over 185 basic formats, including popular tiff, jpeg, gif, png, pdf, and photocd. By using imagemagick, You can dynamically generate images based on the needs of web applications. You can also resize, rotate, sharpen, subtract, or add special effects to one or more images, save the operation results in the same format or other formats.

Components

Http://pecl.php.net/package/imagick
Http://www.imagemagick.org

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.