PHP 中的 imagecreate() 函式
imagecreate() 函式用於建立新影像。建議使用 imagecreatetruecolor() 代替 imagecreate() 來建立影像。這是因為影像處理在使用 imagecreatetruecolor() 建立的質量最好的影像上執行。
語法
imagecreate( $width, $height )
引數
width: 影像的寬度
height: 影像的高度
返回
imagecreate() 函式成功時返回影像資源識別符號,錯誤時返回 FALSE。
示例
以下是一個示例
<?php
$img = imagecreate(500, 300);
$bgcolor = imagecolorallocate($img, 150, 200, 180);
$fontcolor = imagecolorallocate($img, 120, 60, 200);
imagestring($img, 12, 150, 120, "Demo Text1", $fontcolor);
imagestring($img, 3, 150, 100, "Demo Text2", $fontcolor);
imagestring($img, 9, 150, 80, "Demo Text3", $fontcolor);
imagestring($img, 12, 150, 60, "Demo Text4", $fontcolor);
header("Content-Type: image/png");
imagepng($img);
imagedestroy($img);
?>輸出
以下是輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP