日期:2014-05-17 浏览次数:20602 次
$url = 'http://img.bbs.csdn.net/upload/201310/29/1383042869_349074.png';
$im1 = imagecreatefrompng($url);
//这几行必须有,否则原图的阴影层过不来
$im2 = imagecreatetruecolor(imagesx($im1), imagesy($im1));
$bg = imagecolorallocate($im2, 255, 255, 255);
imagefill($im2, 0, 0, $bg);
imagecopy($im2, $im1, 0, 0, 0, 0, imagesx($im1), imagesy($im1));
#设置水印字体颜色
$color = imagecolorallocatealpha($im2,0,0,0,100);
#设置字体文件路径
$fontfile = "msyhbd.ttf";
$fontfile = "c:/windows/fonts/FZJZJW.TTF";
#水印文字
$str = "我们都是好孩子";
$str = iconv('gbk', 'utf-8', $str);
#打水印
imagettftext($im2,20,20,20,100,$color,$fontfile,$str);
imagettftext($im2,20,20,30,200,$color,$fontfile,$str);
imagettftext($im2,20,20,40,300,$color,$fontfile,$str);
imagepng($im2);