(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源图象的高度。
成功时返回 true, 或者在失败时返回 false。
| 版本 | 说明 |
|---|---|
| 8.0.0 |
dst_image 和 src_image
现在需要 GdImage 实例;之前需要 resource。
|
示例 #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);
?>
以上例程的输出类似于: