php 图片上添加透明度渐变的效果

yipeiwu_com6年前PHP代码库

复制代码 代码如下:

<?php
////$strimgsrc = file_get_contents("/zb_users/upload/202003/e4lf1fxwbqa.jpg");
////$imgsrc = imagecreatefromstring($strimgsrc);
$imgsrc = imagecreatefromjpeg("5307754.jpg");
$imgsrcw = imagesx($imgsrc);
$imgsrch = imagesy($imgsrc);
$width = 30;
$x1 = 2;
$x2 = $imgsrcw - $x1 - 20;
$y1 = ($imgsrch - $width) - 2;
$y2 = $y1 + $width;
$steps = $x2 - $x1;
for($i = 0; $i < $steps; $i ++)
{
$alphax = round($i/($steps/127))+60;
if($alphax >= 128)
$alphax = 127;
$alpha = imagecolorallocatealpha($imgsrc, 255, 255, 255, $alphax);
imagefilledrectangle($imgsrc, ($i+$x1), $y1, ($i+$x1+1), $y2, $alpha);
}
header('content-type: image/jpeg');
imagejpeg($imgsrc);
imagedestroy($imgsrc);
?>

相关文章

探讨php中遍历二维数组的几种方法详解

在PHP应用当中,二维数组的应用算是高频率的了,尤其遇到较为复杂的计算时,基本上都要用到二维或者多维数组的,而在编历多维数组使用的较多的应该是 for 循环遍历和 foreach 遍历两...

php获取指定范围内最接近数的方法

本文实例讲述了php获取指定范围内最接近数的方法。分享给大家供大家参考。具体实现方法如下: // Returns the next higher or lower number fu...

PHP 利用Mail_MimeDecode类提取邮件信息示例

重点为one_mail函数。利用Mail_mimeDecode类从邮件中提取邮件头和邮件正文。 复制代码 代码如下: <?php header("content-type:text...

PHP技术开发技巧分享

1. 提高PHP的运行效率   PHP的优点之一是速度很快,对于一般的网站应用,可以说是已经足够了。不过如果站点的访问量很高、带宽窄或者其它的因素令服务器产生性能瓶颈的时候,你可能得想想...

PHP 实现公历日期与农历日期的互转换

PHP 实现公历日期与农历日期的互转换 前言:  今天根据客户的需求对时间进行了转换,就是客户要求增加农历日期的显示,在网上抄袭了一段,稍微修改了一下运行成功了,不难的,改动的...