一聚教程网:一个值得你收藏的教程网站

热门教程

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

时间:2022-06-24 21:09:40 编辑:袖梨 来源:一聚教程网

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

热门栏目