imagecopymergegray() converts the source image to grayscale and then copies all (or a portion) of an image and merges it with another canvas by $percent

imagecopymergegray($dest_r, $src_r, $dest_x, $dest_y, $src_x, $src_y, $src_w, $src_h, $percent);

<?php
    define
("SRC_FILE""php.png");
    
    
$img imagecreatefrompng(SRC_FILE);
    
$img_copy imagecreatefrompng(SRC_FILE);
    
    
imagecopymergegray($img_copy$img101000,
                   
imagesx($img), imagesy($img), 50);
    
    
header("Content-Type: image/png");
    
imagepng($img_copy);
?>