PHP 中的 imagecopymergegray() 函数


imagecopymergegray() 函数用于使用灰度复制并合并一部分图像。

语法

imagecopymerge ( dst_img, src_img, dst_x, dst_y, src_x, src_y, src_w, src_h, pct )

参数

  • dst_im 
    设置目标图像链接资源。

  • src_im 
    设置源图像链接资源。

  • dst_x
    设置目标点的 x 坐标。

  • dst_y 
    设置目标点的 y 坐标。

  • src_x 
    设置源点的 x 坐标。

  • src_y 
    设置源点的 y 坐标。

  • src_w 
    设置源宽度。

  • src_h 
    设置源高度。

  • pct 
    src_im 将根据 pct 转换为灰度,其中 0 为完全灰度,100 为保持不变。

返回

imagecopymergegray() 函数在成功时返回 TRUE,在失败时返回 FALSE。

示例

以下是示例

<?php
   $destImg = imagecreatefromgif('https://tutorialspoint.com/images/html.gif');
   $srcImg = imagecreatefromgif('https://tutorialspoint.com/images/html.gif');
   imagecopymergegray($destImg, $srcImg, 10, 10, 0, 0, 350, 120, 60);
   header('Content-Type: image/png');
   imagegif($destImg);
   imagedestroy($destImg);
   imagedestroy($srcImg);
?>

输出

以下是输出

示例

我们看看另一个示例,在该示例中,我们设置了不同的 x 和 y 坐标

<?php
   $destImg = imagecreatefromgif('https://tutorialspoint.com/images/html.gif');
   $srcImg = imagecreatefromgif('https://tutorialspoint.com/images/html.gif');
   imagecopymergegray($destImg, $srcImg, 20, 10, 0, 0, 410, 130, 100);
   header('Content-Type: image/png');
   imagegif($destImg);
   imagedestroy($destImg);
   imagedestroy($srcImg);
?>

输出

以下是输出

更新日期:31-12-2019

42 次浏览

开启您的 职业生涯

完成课程即可获得认证

开始
广告
© . All rights reserved.