因為工作需求,研究了一下圖片中產生文字的程式,之前會動到圖片函式都是縮圖裁切,或是修改驗證碼才會動到。
這次是單獨為了產生文字圖片而需要使用的程式。
首先 Google 一下 最簡單的生出圖片的方式就是利用GD來產生 :
<?php header("Content-type: image/png"); //設定圖檔格式 $im = @imagecreatetruecolor(80, 20) or die("無法建立圖片!"); //建立一張全彩圖 $text_color = imagecolorallocate($im, 255, 255, 255); //設定文字顏色 imagestring($im, 2, 5, 2, "Hi! I'm Tad", $text_color); //將字串加入圖片中 imagepng($im); //產生圖片 imagedestroy($im); //結束$im釋放記憶體 ?>