imagecreatefromgd2part

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

imagecreatefromgd2part從給定的 GD2 文件或 URL 中的部分新建一圖像

說明

imagecreatefromgd2part(
    string $filename,
    int $srcX,
    int $srcY,
    int $width,
    int $height
): resource

Create a new image from a given part of GD2 file or URL.

小技巧

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

參數(shù)

filename

Path to the GD2 image.

srcX

x-coordinate of source point.

srcY

y-coordinate of source point.

width

源圖象的寬度。

height

源圖象的高度。

返回值

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

范例

示例 #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'44, ($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($imIMG_FILTER_EMBOSS);
}

// Save optimized image
imagegd2($im'./test_emboss.gd2');
imagedestroy($im);
?>

注釋