imagecopymergegray() copy và merge một phần ảnh nguồn vào ảnh đích, chuyển ảnh nguồn sang xám (grayscale) theo phần trăm.
Cú pháp
imagecopymergegray(resource $dst, resource $src, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): bool
Tham số
- dst, src: Resource ảnh đích và nguồn.
- dst_x, dst_y: Tọa độ góc trên-trái nơi dán trên ảnh đích.
- src_x, src_y, src_w, src_h: Vùng cắt trên ảnh nguồn.
- pct: Phần trăm grayscale (0 = hoàn toàn xám, 100 = giữ nguyên màu).
Ví dụ
<?php
$dest = imagecreatefromgif('https://example.com/html.gif');
$src = imagecreatefromgif('https://example.com/html.gif');
imagecopymergegray($dest, $src, 10, 10, 0, 0, 350, 120, 60); // 60% màu, 40% xám
header('Content-Type: image/png');
imagegif($dest);
imagedestroy($dest); imagedestroy($src);
?>