php技术博客
让天下没有搞不定的bug~

php的imagettftext 函数出现乱码的解决方法

php的imagettftext 函数出现乱码的解决方法:

今天遇到一个问题,就是往图片上打文字水印,当是汉字的时候出现了乱码,是英文时候并没有出现乱码,看手册的时候,如果是汉字必须进行转码,比如:

string mb_convert_encoding ( string $str, string $to_encoding [, mixed $from_encoding] )
       来进行转码,再输出
     如:     $str = mb_convert_encoding($str, “UTF-8”, “GB2312”);

 //把生成的文字区域写入到图片文件里

//  $from_groundimage      要打水印的图片

//  $fontsize   字体颜色

//  $pos_x     $pos_y   字体位置

//  $R,$G,$B  控制字体颜色

//  $fontfamily   字体格式

//  $marktext   要打印的字体,字体的位置要对

imagettftext($from_groundimage, $fontsize, 0, $pos_x, $pos_y, imagecolorallocate($from_groundimage,$R,$G,$B),

$fontfamily, $marktext);

赞(0)
未经允许不得转载:PHP技术博客 » php的imagettftext 函数出现乱码的解决方法