求助:php文字水印问题

杜杜儿 2010-08-03 03:30:14

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

我的文件编码是GBK的!是不是什么地方写错了!
望大家多指导!
...全文
162 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
杜杜儿 2010-08-09
  • 打赏
  • 举报
回复
谢谢楼上的!
我还一位是前面加了“@”会有错呢!
wm501903161 2010-08-03
  • 打赏
  • 举报
回复
具说区分大小写,可是我一直以来写都觉得大小写不影响。
kyzy_yy_pm 2010-08-03
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 xuzuning 的回复:]
函数是不分大小写的,自己写错了怪谁呢?

ImageCreateFormGIF
imagecreatefromgif
[/Quote]
貌似大小写没事,我试过
phper_cd 2010-08-03
  • 打赏
  • 举报
回复
调试的时候屏蔽错误时最愚蠢的做法
xuzuning 2010-08-03
  • 打赏
  • 举报
回复
函数是不分大小写的,自己写错了怪谁呢?

ImageCreateFormGIF
imagecreatefromgif
杜杜儿 2010-08-03
  • 打赏
  • 举报
回复
搞定了!
$im=@ImageCreateFormGIF($image); 错误写法
$im=imagecreatefromgif($image);正确写法
难道PHP还区分大小写!
gwn1902 2010-08-03
  • 打赏
  • 举报
回复
有报错么
杜杜儿 2010-08-03
  • 打赏
  • 举报
回复
我知道那个CSS3
可是我用的是PHP 再说现在很多浏览器还不支持CSS3!
只能用水印的办法了!
gwn1902 2010-08-03
  • 打赏
  • 举报
回复
图片上面加水印,css也能实现
杜杜儿 2010-08-03
  • 打赏
  • 举报
回复
我现在改成这样还是不行:
大家帮我想想办法!谢谢!
<?php
// Set the content-type
header("Content-type: image/png");
// Create the image
$image="D:\wamp\www\PKSEO\shuiyin\waterImage.gif";
$im=@ImageCreateFormGIF($image);
//取得图片的大小
// 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=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()
imagegif($im);
imagedestroy($im);
?>
杜杜儿 2010-08-03
  • 打赏
  • 举报
回复

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

我现在改成这样了!可以打中文字 并且不出现乱码
但是我要在图片上水印文字。又出现乱码!
请问应该怎么样写?
q107770540 2010-08-03
  • 打赏
  • 举报
回复
顶。、。。。。。
杜杜儿 2010-08-03
  • 打赏
  • 举报
回复
大家帮我看看! 菜鸟谢过大家了!

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧