21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
header("Content-type: image/jpeg");
$image="D:\wamp\www\PKSEO\shuiyin\waterImage.gif";
//取得图片的大小
$img=GetImageSize($image);
//$img[2] 中存储的是图片的格式
switch($img[2])
{
case 1:
$im=@ImageCreateFormGIF($image);
break;
case 2:
$im=@ImageCreateFormJPEG($image);
break;
case 3:
$im=@ImageCreateFormPNG($image);
break;
}
//文字水印
$tc=imagecolorallocate($im,255,255,255);//颜色
$str=iconv("gbk","utf-8","新年");//输出内容
imagettftext($im,12,0,20,20,$tc,'C:\WINDOWS\Fonts\SIMSUN.TTC',$str);//写入图片
imagejpeg($im);
imagedestroy($im);
?>
<?php
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = imagecreatetruecolor(400,30);
// Create some colors
$white = imagecolorallocate($im,255,255,255);
$grey = imagecolorallocate($im,128,128,128);
$black = imagecolorallocate($im,0,0,0);
// The text to draw
//$text = '扬帆';
$text=iconv("gbk","utf-8","新年");//输出内容
// Replace path by your own font path
$font = 'C:\WINDOWS\Fonts\SIMSUN.TTC';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21,$grey,$font,$text);
// Add the text
imagettftext($im, 20, 0, 10, 20,$white,$font,$text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>