오늘 저는 GD와 관련된 몇 가지 기술을 주의 깊게 연구했고, GD의 한자 왜곡 문제도 연구했습니다.
GD 라이브러리를 사용하여 중국어 문자열을 출력하면 imagestring을 호출하는 것은 쓸모가 없습니다. imagettftext() 함수를 사용해야 합니다. imagettftext 함수의 구체적인 사용법은 매뉴얼을 참고하세요.
사용 예는 다음과 같습니다.
<span><code><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>
$pic=imagecreate(250,30); $black=imagecolorallocate($pic,0,0,0) <span><p><span><?php </p>$pic</SPAN><SPAN>=</SPAN><SPAN>이미지 생성</SPAN ><SPAN>(</SPAN><SPAN>250</SPAN><SPAN>,</SPAN><SPAN>30</SPAN><SPAN>) <p></SPAN><SPAN>$black </SPAN><SPAN>=</SPAN><SPAN>이미지 색상 할당</SPAN><SPAN>(</SPAN><SPAN>$pic</SPAN><SPAN>,</SPAN><SPAN>0< /SPAN><SPAN>,</SPAN><SPAN>0</SPAN><SPAN>,</SPAN><SPAN>0</SPAN><SPAN>) </p></SPAN><SPAN> $white</SPAN><SPAN>=</SPAN><SPAN>이미지 색상 할당</SPAN><SPAN>(</SPAN><SPAN>$pic</SPAN><SPAN>,</SPAN><SPAN> 255</SPAN><SPAN>,</SPAN><SPAN>255</SPAN><SPAN>,</SPAN><SPAN>255</SPAN><SPAN>) <🎜></SPAN>< SPAN>$font</SPAN><SPAN>=</SPAN><SPAN>"C://WINDOWS//Fonts//simhei.ttf"</SPAN><SPAN> <🎜></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> <🎜></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>) <🎜></SPAN><SPAN>헤더</SPAN><SPAN>(</ SPAN><SPAN>"콘텐츠 유형: image/jpeg"</SPAN><SPAN>) <🎜></SPAN><SPAN>$filename</SPAN><SPAN>=</SPAN><SPAN> '../src/images/photo.jpg'</SPAN><SPAN>; <🎜></SPAN><SPAN>$im</SPAN><SPAN>=</SPAN><SPAN>imagecreatefromjpeg</ SPAN><SPAN>(</SPAN><SPAN>$filename</SPAN><SPAN>) <🎜></SPAN><SPAN>이미지 복사 병합</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>) <🎜></SPAN><SPAN> imagejpeg</SPAN><SPAN>(</SPAN><SPAN>$im</SPAN><SPAN>) <🎜></SPAN><SPAN>?></span> </p></span>
위 내용은 포토샵 cs5 중국어 내용을 포함하여 GD 중국어 깨짐 문제를 해결하기 위해 포토샵 cs5 중국어를 소개한 내용입니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되길 바랍니다.