Home > php教程 > php手册 > body text

php 给图片增加背景平铺水印代码

WBOY
Release: 2016-06-13 09:48:30
Original
2259 people have browsed it

如果你想利用php 给图片增加背景平铺水印效果话,必须利用php的一个插件来实例,就是利用imagick,他可以给图片增加背景平铺水印效果哦,下面我们提供一款实例代码。

 如果你想利用php教程 给图片增加背景平铺水印效果话,必须利用php的一个插件来实例,就是利用imagick,他可以给图片增加背景平铺水印效果哦,下面我们提供一款实例代码。


imagemagic官方去除图片背景的命令行模式:

convert -size 140x80 xc:none -fill grey           -gravity northwest -draw "text 10,10 'copyright'"           -gravity southeast -draw "text 5,15 'copyright'"           miff:- |    composite -tile - logo.jpg  wmark_text_tiled.jpg


imagick代码:

$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();
?>

如果你的机型还没装php_imagick就下载吧,下载地址如下

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

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template