Home > Backend Development > PHP Tutorial > PHP adds background tile watermark code to images_PHP tutorial

PHP adds background tile watermark code to images_PHP tutorial

WBOY
Release: 2016-07-13 10:45:32
Original
1303 people have browsed it

If you want to use PHP to add a background tiled watermark effect to an image, you must use a plug-in in PHP to give an example, that is, use imagick, which can add a background tiled watermark effect to an image. Below we provide an example code .

If you want to use the php tutorial to add the background tiled watermark effect to the image, you must use a plug-in in php to implement it, that is, use imagick, which can add the background tiled watermark to the image. EffectOh, we provide an example code below.


imagemagic official command line mode to remove image background:

convert -size 140x80 xc:none -fill gray                                 -gravity northwest -draw "text 10,10 'copyright'"              -gravity southeast -draw "text 5,15 'copyright'"                                                                                                                                          - .jpg wmark_text_tiled.jpg


imagick code:

$image = new imagick('logo.jpg');
$im = new imagick();
$im->newimage( 140, 80, new imagickpixel( "none" ) );
$draw = new imagickdraw();
$draw->setfillcolor(new imagickpixel( "grey" ));
$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 your model has not installed php_imagick, please download it. The download address is as follows

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633008.htmlTechArticleIf you want to use php to add a background tile watermark effect to the image, you must use a plug-in in php to implement it. Just use imagick, he can add a background tile watermark effect to the picture...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template