Php adds the background tile watermark code to the image

Source: Internet
Author: User

Command line mode for imagemagic to remove image backgrounds:

The code is as follows: Copy code
Convert-size 140x80 xc: none-fill gray-gravity northwest-draw "text 'copyright'"-gravity southeast-draw "text 'copyright'" miff: -| composite-tile-logo.jpg wmark_text_tiled.jpg


Imagick code:

The code is as follows: Copy code
<? Php
$ Image = new imagick('logo.jpg ');
$ Im = new imagick ();
$ Im-> newimage (140, 80, new imagickpixel ("none "));
$ Draw = new imagickdraw ();
$ Draw-> setfillcolor (new imagickpixel ("gray "));
$ Draw-> setgravity (imagick: gravity_northwest );
$ Draw-> annotation (10, 10, 'copyright ');
$ Draw-> setgravity (imagick: gravity_southeast );
$ Draw-> annotation (5, 15, 'copyright ');
$ Im-> drawimage ($ draw );
$ Image = $ image-> textureimage ($ im );
$ Image-> compositeimage ($ image, imagick: composite_copy, 0, 0 );
Header ("content-type: image/{$ image-> getimageformat ()}");
$ Image-> writeimage('wmark_text_tiled.jpg ');
$ Image-> clear ();
$ Image-> destroy ();
?>

If you have not installed php_imagick on your model, download it as follows:

Http://pecl.php.net/package/imagick

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.