(PHP 4 >= 4.0.7, PHP 5)
imagecreatefromgd2part — 從給定的 GD2 文件或 URL 中的部分新建一圖像
說明
resource imagecreatefromgd2part ( string$filename
, int $srcX
, int $srcY
, int $width
, int $height
)
Create a new image from a given part of GD2 file or URL.
Tip如已啟用fopen 包裝器,在此函數中, URL 可作為文件名。關于如何指定文件名詳見 fopen()。各種 wapper 的不同功能請參見 支持的協議和封裝協議,注意其用法及其可提供的預定義變量。
參數
filename
Path to the GD2 image.
srcX
x-coordinate of source point.
srcY
y-coordinate of source point.
width
源圖象的寬度。
height
源圖象的高度。
返回值
成功后返回圖象資源,失敗后返回 FALSE
。
范例
Example #1 imagecreatefromgd2part() example
<?php
// For this example we need the image size before
$image = getimagesize('./test.gd2');
// Create the image instance now we got the image
// sizes
$im = imagecreatefromgd2part('./test.gd2', 4, 4, ($image[0] / 2) - 6, ($image[1] / 2) - 6);
// Do an image operation, in this case we emboss the
// image if PHP 5+
if(function_exists('imagefilter'))
{
imagefilter($im, IMG_FILTER_EMBOSS);
}
// Save optimized image
imagegd2($im, './test_emboss.gd2');
imagedestroy($im);
?>
注釋
Note: 此函數需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。
WarningWindows 版本的 PHP 在 4.3.0 版之前不支持通過此函數訪問遠程文件,即使已經啟用 allow_url_fopen.