Today, a careful study of the next GD some of the relevant technology, conveniently also studied under the GD Chinese garbled problem.
Using the GD library to output Chinese strings, calling imagestring is no use. You need to use the Imagettftext () function. The specific use of the Imagettftext function is the reference manual.
Here is a usage example:
$pic=imagecreate(250,30);
$black=imagecolorallocate($pic,0,0,0);
$white=imagecolorallocate($pic,255,255,255);
$font="C://WINDOWS//Fonts//simhei.ttf"; //这里的路进需要注意下,必须是字符的路径
$str ='php'.iconv('gb2312','utf-8','面对对象')." www.phpobject.net";
imagettftext($pic,10,0,10,20,$white,$font,$str);
I gave a simple example of GD watermark, just for example to illustrate how to use the image watermark, here gives a simple text watermark code.
<?php
$pic=Imagecreate(250,30);
$black=Imagecolorallocate($pic,0,0,0);
$white=Imagecolorallocate($pic,255,255,255);
$font="C://windows//fonts//simhei.ttf";
$str=' PHP '.Iconv(' gb2312 ',' Utf-8 ',' Face the object ')."Www.phpobject.net";
Imagettftext($pic, , 0 , ten , , $white , $font , $ STR );
Header ( "Content-type: image/jpeg" );
$filename = ' ... /src/images/photo.jpg ' ;
$im = imagecreatefromjpeg ( $filename );
imagecopymerge ( $im , $pic , 0 , 0 , 0 , 0 , up , , );
imagejpeg ( $im );
?>