imagecopy() copy một vùng hình chữ nhật từ ảnh nguồn sang ảnh đích (không blend, không scale).
Cú pháp
imagecopy(resource $dst, resource $src, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h): bool
Tham số
- dst, src: Resource ảnh đích và nguồn.
- dst_x, dst_y: Tọa độ dán trên ảnh đích.
- src_x, src_y, src_w, src_h: Vùng cắt trên ảnh nguồn.
Ví dụ
<?php
$src = imagecreatefromgif('https://example.com/html.gif');
$dest = imagecreatetruecolor(170, 140);
imagecopy($dest, $src, 0, 0, 0, 0, 180, 260); // copy toàn bộ src vào dest (có thể cắt)
header('Content-Type: image/gif');
imagegif($dest);
imagedestroy($dest); imagedestroy($src);
?>