:::

14. 線上影像合成

一、建立基本GD圖檔

<?php
header("Content-type: image/png");
$im = @imagecreatetruecolor(120, 60) or die("無法建立GD圖片");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

二、常用GD函數

1.resource imagecreate(int $寬 , int $高)    //建立畫布
2.resource imagecreatetruecolor(int $寬 , int $高) //建立全彩畫布
3.int imagecolorallocate(resource $im ,int $紅 ,int $綠 ,int $藍)//定義顏色
4.bool imagefill ( resource $image , int $x , int $y , int $color )
5.bool imagestring(resource $im , int $字型 , int $x , int $y , string $內容 , int $顏色)    //欲寫入的字串,字型是1~5,為內建的英文字型
6.bool imagepng(resource $im [, string $檔名 [, int $品質 [, int $濾鏡]]])
7.bool imagedestroy(resource $im) //釋放記憶體

三、加入中文字型

1.array imagettftext(resource $im , float $大小  , float $角度  , int $x  , int $y  , int $顏色  , string $字型檔  , string $文字)

四、在現有圖檔建立GD圖

1.resource imagecreatefrompng(string $檔名)

五、插入圖片

1.bool imagecopy( resource $目的  , resource $來源  , int $目的_x  , int $目的_y  , int $來源_x  , int $來源_y  , int $來源寬 , int $來源高)
2.bool imagecopyresized(resource $目的  , resource $來源  , int $目的_x  , int $目的_y  , int $來源_x  , int $來源_y  , int $目的寬  , int $目的高  , int $來源寬 , int $來源高)
3.bool imagecopyresampled(resource $目的  , resource $來源  , int $目的_x  , int $目的_y  , int $來源_x  , int $來源_y  , int $目的寬  , int $目的高  , int $來源寬 , int $來源高)
<?php
header("Content-type: image/png");
$im = imagecreatefrompng("blank_logo.png") or die("無法建立GD圖片");
$background_color = imagecolorallocate($im, 255, 100, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$im2 = imagecreatefrompng("icon/Find.png") or die("無法建立GD圖片");
imagecopyresampled( $im  , $im2  , 30  , 0  , 0  , 0 , 32,32 , 256 , 256);
imagettftext($im , 9 , 0 , 5  , 48  , $text_color  , "fireflysung.ttf" , "中文字測試");
imagepng($im);
imagedestroy($im);
?>


:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D8%26tbdsn%3D215

書籍目錄

展開 | 闔起

線上使用者

29人線上 (4人在瀏覽線上書籍)

會員: 0

訪客: 29

更多…