那首先呢 我們先獲取本地或者服務器上的圖片
$img = SERCURITY_RES.'/1234567.jpg';
$imgs = file_get_contents($img);
$im = @imagecreatefromstring($imgs) or die ("打開圖片失敗!");//創建一個圖像資源從字符串中的圖像流。
接下來就要用到這個函數 imageTTFText();
它的語法呢 array ImageTTFText(int im, int size, int angle, int x, int y, int col, string fontfile, string text);
返回值:數組
函數種類:圖形處理
函數介紹:本函數將 TTF (TrueType Fonts) 字型文字寫入圖片。參數 size 爲字形的尺寸;angle 爲字型的角度,順時針計算,0 度爲水平,也就是三點鐘的方向 (由左到右),90 度則爲由下到上的文字;x,y 二參數爲文字的座標值 (原點爲左上角);參數 col 爲字的顏色;fontfile 爲字型文件名稱,亦可是遠端的文件;text 當然就是字符串內容了。返回值爲數組,包括了八個元素,頭二個分別爲左下的 x、y 座標,第三、四個爲右下角的 x、y 座標,第五、六及七、八二組分別爲右上及左上的
x、y 座標。治募注意的是欲使用本函數,系統要裝妥 GD 及 Freetype 二個函數庫。
那這裏就是你要處理的內容 想要王圖片上增加的文字信息
<?php
Header("Content-type: image/gif");
$im = imagecreate(400,30);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageTTFText($im, 20, 0, 10, 20, $white, "/somewhere/arial.ttf", "I am NUMBER ONE !!");//最後就是加到圖片上的文字
ImageGif($im);
ImageDestroy($im);
?>