imagecreatefromgd2

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

imagecreatefromgd2從 GD2 文件或 URL 新建一圖像

說明

imagecreatefromgd2(string $filename): resource

從 GD2 文件或 URL 新建一圖像。

小技巧

如已啟用fopen 包裝器,在此函數(shù)中, URL 可作為文件名。關(guān)于如何指定文件名詳見 fopen()。各種 wapper 的不同功能請參見 支持的協(xié)議和封裝協(xié)議,注意其用法及其可提供的預(yù)定義變量。

參數(shù)

filename

GD2 圖像的路徑。

返回值

成功后返回圖象對象,失敗后返回 false

范例

示例 #1 imagecreatefromgd2() 例子

<?php
// 加載 gd2 圖像
$im imagecreatefromgd2('./test.gd2');


// 在圖像上應(yīng)用效果。
// 在這個例子中,如果版本為 PHP5+ 則反轉(zhuǎn)圖像顏色
if(function_exists('imagefilter'))
{
    
imagefilter($imIMG_FILTER_NEGATE);
}

// 保存圖像
imagegd2($im'./test_updated.gd2');
imagedestroy($im);
?>

注釋