PHP imagecreate - 新建一個基於調色板的圖像

PHP 圖像處理PHP 圖像處理

imagecolorallocate — 新建一個基於調色板的圖像。

語法

imagecreate ( int $x_size , int $y_size ) : resource

imagecolorallocate() 返回一個圖像識別字,代表了一幅大小為 x_size 和 y_size 的空白圖像。

實例

<?php
header("Content-type: image/png");
$im = @imagecreate(100, 50)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

PHP 圖像處理PHP 圖像處理