今天仔细研究了下GD的一些相关技术,顺手也研究下GD中文乱码的问题。
使用GD库输出中文字符串,调用imagestring是没有用的。需要使用imagettftext()函数。imagettftext函数的具体使用就参考手册啦。
下面给个使用实例:
<span><br>$pic=imagecreate(250,30); <br>$black=imagecolorallocate($pic,0,0,0); <br>$white=imagecolorallocate($pic,255,255,255); <br>$f><code><span><br><span><?php <BR>$pic</span><span>=</span><span>imagecreate</span><span>(</span><span>250</span><span>,</span><span>30</span><span>); <br></span><span>$black</span><span>=</span><span>imagecolorallocate</span><span>(</span><span>$pic</span><span>,</span><span>0</span><span>,</span><span>0</span><span>,</span><span>0</span><span>); <br></span><span>$white</span><span>=</span><span>imagecolorallocate</span><span>(</span><span>$pic</span><span>,</span><span>255</span><span>,</span><span>255</span><span>,</span><span>255</span><span>); <br></span><span>$font</span><span>=</span><span>"C://WINDOWS//Fonts//simhei.ttf"</span><span>; <br></span><span>$str </span><span>=</span><span>'php'</span><span>.</span><span>iconv</span><span>(</span><span>'gb2312'</span><span>,</span><span>'utf-8'</span><span>,</span><span>'面对对象'</span><span>).</span><span>" www.phpobject.net"</span><span>; <br></span><span>imagettftext</span><span>(</span><span>$pic</span><span>,</span><span>10</span><span>,</span><span>0</span><span>,</span><span>10</span><span>,</span><span>20</span><span>,</span><span>$white</span><span>,</span><span>$font</span><span>,</span><span>$str</span><span>); <br></span><span>header</span><span>(</span><span>"Content-type: image/jpeg"</span><span>); <br></span><span>$filename</span><span>=</span><span>'../src/images/photo.jpg'</span><span>; <br></span><span>$im</span><span>=</span><span>imagecreatefromjpeg</span><span>(</span><span>$filename</span><span>); <br></span><span>imagecopymerge</span><span>(</span><span>$im</span><span>,</span><span>$pic</span><span>,</span><span>0</span><span>,</span><span>0</span><span>,</span><span>0</span><span>,</span><span>0</span><span>,</span><span>250</span><span>,</span><span>30</span><span>,</span><span>50</span><span>); <br></span><span>imagejpeg</span><span>(</span><span>$im</span><span>); <br></span><span>?></span> <br> </span>
以上就介绍了photoshop cs5 中文 解决GD中文乱码问题,包括了photoshop cs5 中文方面的内容,希望对PHP教程有兴趣的朋友有所帮助。