php如何使用GD库添加水印呢?
使用GD库添加水印的步骤如下:
1、创建一个透明的图片,不能对www.phpdo.net 有任何的遮挡;
2、将这张图像放置在页面上。
例如:
<?php
header("Content-type:image/png");
$conn = mysql_connect("localhost","root","");
$colname_rs_article = $_GET['id'];
mysql_select_db("cms",$conn);
$query_rs_article = sprintf("select * from articles where article_id=%s",$colname_rs_article);
$rs_article = mysql_query($query_rs_article,$conn)
or die(mysql_error());
$row_rs_article = mysql_fetch_assoc($rs_article);
$totalRows_rs_article = mysql_num_rows($rs_article);
$image = imagecreatetruecolor(700,1000);
$bg = imagecolorallocate($image,255,255,255);
imagefill($image,0,0,$bg);
$text_color = imagecolorallocate($image,0,0,0);
imagestring($image,5,0,0,$row_rs_article['title'],$text_color);
imagestring($image,3,0,20,$row_rs_article['author'],$text_color);
imagestring($image,4,0,60,$row_rs_article['content'],$text_color);
//添加水印
$logo = imagecreatefrompng('logo.png');
$logoW = imagesx($logo);
$logoH = imagesy($logo);
imagecopy($image,$logo,0,0,0,0,$logoW,$logoH);
imagejpeg($image);
imagedestroy($logo);
imagedestroy($image);
?>








最新评论
再来浏览一次,上次没看懂。
:evil: 不错啊
博主的技术文章很有帮助
好文章,关注啦!谢谢博主分享
你好 来学习下
我来了哦
第一次来访留个记号
呵呵,哥们越来越勤奋了啊 :
php点点通,(www.ph
:eek: :eek: