{"id":540357,"date":"2021-09-27T23:09:09","date_gmt":"2021-09-27T15:09:09","guid":{"rendered":"http:\/\/4563.org\/?p=540357"},"modified":"2021-09-27T23:09:09","modified_gmt":"2021-09-27T15:09:09","slug":"%e7%bb%a7%e7%bb%ad%e8%af%b7%e6%95%99%e5%a4%a7%e4%bd%ac%e4%b8%aa%e4%bb%a3%e7%a0%81%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=540357","title":{"rendered":"\u7ee7\u7eed\u8bf7\u6559\u5927\u4f6c\u4e2a\u4ee3\u7801\u95ee\u9898"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>fifalan<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>\u7ee7\u7eed\u8bf7\u6559\u5927\u4f6c\u4e2a\u4ee3\u7801\u95ee\u9898<\/h3>\n<p>  \t\t&lt;?php <br \/>  &nbsp; &nbsp; $text=$_REQUEST[&quot;text&quot;];\/\/\u663e\u793a\u7684\u6587\u5b57<br \/>  &nbsp; &nbsp; \/*<br \/>  &nbsp; &nbsp; \u6b65\u9aa4\uff1a<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;1.\u5206\u522b\u521b\u5efa\u5927\u5c0f\u56fe\u753b\u5e03\u5e76\u83b7\u53d6\u5b83\u4eec\u7684\u5bbd\u9ad8<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;2.\u6dfb\u52a0\u6587\u5b57\u6c34\u5370<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;3.\u6267\u884c\u56fe\u7247\u6c34\u5370\u5904\u7406<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;4.\u8f93\u51fa<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;5.\u9500\u6bc1\u753b\u5e03<br \/>  &nbsp; &nbsp;*\/<br \/>  &nbsp; &nbsp; \/\/1.\u5206\u522b\u521b\u5efa\u5927\u5c0f\u56fe\u753b\u5e03\u5e76\u83b7\u53d6\u5b83\u4eec\u7684\u5bbd\u9ad8<br \/>  &nbsp; &nbsp; $big = imagecreatefromjpeg(&#8216;789.jpg&#8217;);<br \/>  &nbsp; &nbsp; $bx = imagesx($big);<br \/>  &nbsp; &nbsp; $by = imagesy($big);<\/p>\n<p>  &nbsp; &nbsp; \/\/2.\u6dfb\u52a0\u6c34\u5370\u6587\u5b57<br \/>  &nbsp; &nbsp; $blue = imagecolorallocate($big,0,10,0);<br \/>  &nbsp; &nbsp; imagettftext($big,20,0,80,140,$blue,&#8217;02.ttf&#8217;,$text);<\/p>\n<p>  &nbsp; &nbsp;<\/p>\n<p>  &nbsp; &nbsp; \/\/4.\u8f93\u51fa\u5230\u6d4f\u89c8\u5668<br \/>  &nbsp; &nbsp; header(&#8216;content-type: image\/jpeg&#8217;);<br \/>  &nbsp; &nbsp; imagejpeg($big);<\/p>\n<p>  &nbsp; &nbsp; \/\/5.\u9500\u6bc1\u753b\u5e03<br \/>  &nbsp; &nbsp; imagedestroy($big);<br \/>  &nbsp; &nbsp;<br \/>  &nbsp; &nbsp; <br \/>   ?&gt;<\/p>\n<p>  \u4ee5\u4e0a\u8fd9\u6bb5\u4ee3\u7801\u600e\u4e48\u8ba9\u4ed6\u6587\u5b57\u6307\u5b9a\u5bbd\u5ea6\u6362\u884c\u5462\uff0c\u83dc\u9e1f\u4e00\u679a\u4e0d\u4f1a\u5f04\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yyy.sg<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\thttps:\/\/www.php.net\/manual\/zh\/function.imagettftext.php<br \/>  \u53c2\u6570 \u00b6<br \/>  image<br \/>  \u7531\u56fe\u8c61\u521b\u5efa\u51fd\u6570(\u4f8b\u5982imagecreatetruecolor())\u8fd4\u56de\u7684\u56fe\u8c61\u8d44\u6e90\u3002<\/p>\n<p>  size<br \/>  \u5b57\u4f53\u7684\u5c3a\u5bf8\uff0c\u5355\u4f4d\uff1a\u70b9\uff08\u78c5\uff09\u3002<\/p>\n<p>  angle<br \/>  \u89d2\u5ea6\u5236\u8868\u793a\u7684\u89d2\u5ea6\uff0c0 \u5ea6\u4e3a\u4ece\u5de6\u5411\u53f3\u8bfb\u7684\u6587\u672c\u3002\u66f4\u9ad8\u6570\u503c\u8868\u793a\u9006\u65f6\u9488\u65cb\u8f6c\u3002\u4f8b\u5982 90 \u5ea6\u8868\u793a\u4ece\u4e0b\u5411\u4e0a\u8bfb\u7684\u6587\u672c\u3002<\/p>\n<p>  x<br \/>  \u7531 x\uff0cy \u6240\u8868\u793a\u7684\u5750\u6807\u5b9a\u4e49\u4e86\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u57fa\u672c\u70b9\uff08\u5927\u6982\u662f\u5b57\u7b26\u7684\u5de6\u4e0b\u89d2\uff09\u3002\u8fd9\u548c imagestring() \u4e0d\u540c\uff0c\u5176 x\uff0cy \u5b9a\u4e49\u4e86\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u5de6\u4e0a\u89d2\u3002\u4f8b\u5982 &quot;top left&quot; \u4e3a 0, 0\u3002<\/p>\n<p>  y<br \/>  Y \u5750\u6807\u3002\u5b83\u8bbe\u5b9a\u4e86\u5b57\u4f53\u57fa\u7ebf\u7684\u4f4d\u7f6e\uff0c\u4e0d\u662f\u5b57\u7b26\u7684\u6700\u5e95\u7aef\u3002<\/p>\n<p>  color<br \/>  \u989c\u8272\u7d22\u5f15\u3002\u4f7f\u7528\u8d1f\u7684\u989c\u8272\u7d22\u5f15\u503c\u5177\u6709\u5173\u95ed\u9632\u952f\u9f7f\u7684\u6548\u679c\u3002\u89c1 imagecolorallocate()\u3002<\/p>\n<p>  fontfile<br \/>  \u662f\u60f3\u8981\u4f7f\u7528\u7684 TrueType \u5b57\u4f53\u7684\u8def\u5f84\u3002<\/p>\n<p>  \u6839\u636e PHP \u6240\u4f7f\u7528\u7684 GD \u5e93\u7684\u4e0d\u540c\uff0c\u5f53 fontfile \u6ca1\u6709\u4ee5 \/ \u5f00\u5934\u65f6\u5219 .ttf \u5c06\u88ab\u52a0\u5230\u6587\u4ef6\u540d\u4e4b\u540e\u5e76\u4e14\u4f1a\u5728\u5e93\u5b9a\u4e49\u5b57\u4f53\u8def\u5f84\u4e2d\u5c1d\u8bd5\u641c\u7d22\u8be5\u6587\u4ef6\u540d\u3002<\/p>\n<p>  \u5f53\u4f7f\u7528\u7684 GD \u5e93\u7248\u672c\u4f4e\u4e8e 2.0.18 \u65f6\uff0c\u4e00\u4e2a\u7a7a\u683c\u5b57\u7b26 \u800c\u4e0d\u662f\u5206\u53f7\u5c06\u88ab\u7528\u6765\u4f5c\u4e3a\u4e0d\u540c\u5b57\u4f53\u6587\u4ef6\u7684\u201c\u8def\u5f84\u5206\u9694\u7b26\u201d\u3002\u4e0d\u5c0f\u5fc3\u4f7f\u7528\u4e86\u6b64\u7279\u6027\u5c06\u4f1a\u5bfc\u81f4\u4e00\u6761\u8b66\u544a\u4fe1\u606f\uff1aWarning: Could not find\/open font\u3002\u5bf9\u53d7\u5f71\u54cd\u7684\u7248\u672c\u6765\u8bf4\u552f\u4e00\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u5c06\u5b57\u4f53\u79fb\u52a8\u5230\u4e0d\u5305\u542b\u7a7a\u683c\u7684\u8def\u5f84\u4e2d\u53bb\u3002<\/p>\n<p>  \u5f88\u591a\u60c5\u51b5\u4e0b\u5b57\u4f53\u90fd\u653e\u5728\u811a\u672c\u7684\u540c\u4e00\u4e2a\u76ee\u5f55\u4e0b\u3002\u4e0b\u9762\u7684\u5c0f\u6280\u5de7\u53ef\u4ee5\u51cf\u8f7b\u5305\u542b\u7684\u95ee\u9898\u3002<\/p>\n<p>  &lt;?php<br \/>  \/\/ Set the enviroment variable for GD<br \/>  putenv(&#8216;GDFONTPATH=&#8217; . realpath(&#8216;.&#8217;));<\/p>\n<p>  \/\/ Name the font to be used (note the lack of the .ttf extension)<br \/>  $font = &#8216;SomeFont&#8217;;<br \/>  ?&gt;<br \/>  text<br \/>  UTF-8 \u7f16\u7801\u7684\u6587\u672c\u5b57\u7b26\u4e32\u3002<\/p>\n<p>  \u53ef\u4ee5\u5305\u542b\u5341\u8fdb\u5236\u6570\u5b57\u5316\u5b57\u7b26\u8868\u793a\uff08\u5f62\u5f0f\u4e3a\uff1a&#8364;\uff09\u6765\u8bbf\u95ee\u5b57\u4f53\u4e2d\u8d85\u8fc7\u4f4d\u7f6e 127 \u7684\u5b57\u7b26\u3002UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u53ef\u4ee5\u76f4\u63a5\u4f20\u9012\u3002<\/p>\n<p>  \u547d\u540d\u5b9e\u4f53\uff0c\u6bd4\u5982 &amp;copy; \u662f\u4e0d\u652f\u6301\u7684\u3002\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 html_entity_decode() \u6765\u89e3\u7801\u547d\u540d\u5b9e\u4f53\u4e3a UTF-8 \u5b57\u7b26\u3002 \uff08\u81ea PHP 5.0.0 \u5f00\u59cb html_entity_decode() \u5f00\u59cb\u652f\u6301\uff09<\/p>\n<p>  \u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528\u7684\u67d0\u4e2a\u5b57\u7b26\u4e0d\u88ab\u5b57\u4f53\u652f\u6301\uff0c\u4e00\u4e2a\u7a7a\u5fc3\u77e9\u5f62\u5c06\u66ff\u6362\u8be5\u5b57\u7b26\u3002\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>fifalan \u5927\u4f6c\u6709\u8bdd\u8bf4 : \u7ee7&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/540357"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=540357"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/540357\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=540357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=540357"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=540357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}