imagecopy
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecopy — 拷贝图像的一部分
说明
imagecopy(
GdImage
GdImage
int
int
int
int
int
int
): bool
GdImage
$dst_image,GdImage
$src_image,int
$dst_x,int
$dst_y,int
$src_x,int
$src_y,int
$src_width,int
$src_height): bool
从 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
// 创建图像实例
$src = imagecreatefromgif('php.gif');
$dest = imagecreatetruecolor(80, 40);
// 复制
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40);
// 输出
header('Content-Type: image/gif');
imagegif($dest);
?>以上示例的输出类似于:
参见
- imagecrop() - Crop an image to the given rectangle