array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagecopy.php', 1 => 'imagecopy', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imageconvolution.php', 1 => 'imageconvolution', ), 'next' => array ( 0 => 'function.imagecopymerge.php', 1 => 'imagecopymerge', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagecopy.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecopy — 拷贝图像的一部分
$dst_image
,$src_image
,$dst_x
,$dst_y
,$src_x
,$src_y
,$src_width
,$src_height
从 x、y 坐标 src_x
、src_y
开始,将 src_image
的一部分复制到 dst_image
上,宽度为 src_width
,高度为 src_height
。定义的部分将被复制到
x,y 坐标 dst_x
和 dst_y
上。
dst_image
目标图象资源。
src_image
源图象资源。
dst_x
目标点的 x 坐标。
dst_y
目标点的 y 坐标。
src_x
源点的 x 坐标。
src_y
源点的 y 坐标。
src_width
源图象的宽度。
src_height
源图象的高度。
示例 #1 裁剪 PHP.net logo
<?php
// Create image instances
$src = imagecreatefromgif('php.gif');
$dest = imagecreatetruecolor(80, 40);
// Copy
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40);
// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);
imagedestroy($dest);
imagedestroy($src);
?>
以上示例的输出类似于: