header("Content-type: image/png");
$str = file_get_contents('txt.txt');//调用文本
$height=200;//图片高度
$width=200;//图片宽度
$im=@imagecreate($width,$height) or die("Cannot Initialize new GD image stream");
//颜色设置
$background_color = imagecolorallocate($im, 255, 255, 255);//背景颜色
$text_color= imagecolorallocate($im, 0, 0, 0);//文字颜色
imagefill($im,0,0,$background_color);//填充背景
$str=iconv("Gb2312","UTF-8",$str);//输入文字
$font = 'arial.ttf';//字体文件
ImageTTFText($im,15/*字体大小*/,0/*旋转*/,10/*左边距*/,20/*上边距*/,$text_color,$font,$str);
imagepng($im);//输出图像
imagedestroy($im);//清理
?>
[ 本帖最后由 zyypp 于 2011-1-31 22:35 编辑 ]
回复 11# 的帖子
well done! 感谢!回复 11# 的帖子
我那段有点问题!帮看看吧! 你既然这样$content=fread($fp,filesize($file_dir));//读文件
用了,为何下面不调用它呢
已经帮你修改好了header("Content-type:image/png");
$file_dir="verchk.txt";
$fp=fopen($file_dir,"r");
$content=fread($fp,filesize($file_dir));//读文件
fclose($fp);
$fplen=strlen($content);
//计算字符字数
$mailaddressimages=imagecreate($fplen*10,25);
//获得文件名图片信息。
$lenadd=$fplen;
$fontsize="4";
$center=(imagesx($mailaddressimages)-8.3*strlen($content))/2;
$mailimagesbackground=ImageColorAllocate($mailaddressimages,231,196,43);
$mailimagesfacecolor=ImageColorAllocate($mailaddressimages,0,0,0);
ImageString($mailaddressimages,$fontsize,$center,5,$content,$mailimagesfacecolor);
Imagepng($mailaddressimages);
ImageDestroy($mailaddressimages);
页:
1
[2]