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

yipeiwu_com5年前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实现向javascript传递数组的方法

本文实例讲述了php实现向javascript传递数组的方法。分享给大家供大家参考。具体如下: 这里介绍的PHP进行数组传值给javascript的技巧,此方法适用php5.2以上,ph...

PHP单元测试利器 PHPUNIT深入用法(二)第1/2页

PHP单元测试利器 PHPUNIT深入用法(二)第1/2页

1、markTestSkipped和markTestIncomplete   在phpunit中,有两个有用的方法markTestSkipped和markTestIncomplete。...

一键生成各种尺寸Icon的php脚本(实例)

实例如下: <?php /** * @name thumb 缩略图函数 * @param sting $img_name 图片路径 * @param...

PHP异常Parse error: syntax error, unexpected T_VAR错误解决方法

其实,这是一个非常容易解决掉的问题。在我看来,似曾相识,呵呵,最近学JavaScript可是学会了使用var声明变量。 其实,在PHP中根本不需要使用var声明的,但是当一个变量作为一个...

fsockopen pfsockopen函数被禁用,SMTP发送邮件不正常的解决方法

一:近期黑客利用程序漏洞注入后使用 fsockopen 进行PHPDDOS 攻击,导致部分服务器不稳定,现在将危险函数 fsockopen 暂时禁用,部分程序功能可能有问题,以下列出已知...