從 GD2 檔案或 URL 新建一影象

imagecreatefromgd2

(PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8)

imagecreatefromgd2 — 從 GD2 檔案或 URL 新建一影象

說明

imagecreatefromgd2(string $filename): resource

從 GD2 檔案或 URL 新建一影象。

小技巧

如已啟用fopen 包裝器,在此函式中, URL 可作為檔名。關於如何指定檔名詳見 fopen()。各種 wapper 的不同功能請參見 支援的協議和封裝協議,注意其用法及其可提供的預定義變數。

參數

filename

GD2 影象的路徑。

返回值

成功后返回圖像對像,失敗后返回 false。

範例

示例 #1 imagecreatefromgd2() 例子

<?php
// 載入 gd2 影象
$im = imagecreatefromgd2('./test.gd2');


// 在影象上應用效果。
// 在這個例子中,如果版本為 PHP5+ 則反轉影象顏色
if(function_exists('imagefilter'))
{
    
imagefilter($im, IMG_FILTER_NEGATE);
}

// 儲存影象
imagegd2($im, './test_updated.gd2');
imagedestroy($im);
?>

註釋

Leave a Reply

Your email address will not be published. Required fields are marked *