©
                    本文档使用
                    php中文网手册 发布
                
(PHP 4 >= 4.0.7, PHP 5, PHP 7)
imagecreatefromgd2part — 从给定的 GD2 文件或 URL 中的部分新建一图像
$filename 
    ,  int $srcX 
    ,  int $srcY 
    ,  int $width 
    ,  int $height 
    )Create a new image from a given part of GD2 file or URL.
如已启用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 及更高版本)。
Windows 版本的 PHP 在 4.3.0 版之前不支持通过此函数访问远程文件,即使已经启用 allow_url_fopen.