`
hcmfys
  • 浏览: 349566 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

php图片支持中文

    博客分类:
  • php
阅读更多
<?php
// 设定图像编码头部
header("Content-type: image/png");
// 创建图像
$im = imagecreatetruecolor(800, 600);
//创建颜色
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 800, 600, $white);
// 绘制的字符
$text = '学习中php';
// 导入字体 在  c:/windows/fonts/simkai.ttf     
$font = 'simkai.ttf';
// Add some shadow to the text
$text=iconv("gb2312","utf-8",$text);
imagettftext($im,20,20, 11, 110, $grey, $font, $text);
// Add the text
imagettftext($im,70,0,10,200, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?> 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics