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使用ftp远程上传文件类(完美解决主从文件同步问题的方法)

php使用ftp实现文件上传代码片段: <?php /** * ftp上传文件类 */ class Ftp { /** *...

php实现验证邮箱格式的代码实例

验证邮箱格式是否正确可以通过filter_var函数来实现。函数介绍:filter_var() 函数通过指定的过滤器过滤一个变量。语法: filter_var(variable, ...

php使用sql数据库 获取字段问题介绍

在PB开发过程中,由于数据库中使用了 ntext字段,出现以下提示错误,郁闷了很长时间找不到解决方案,后查阅大量资料,终于明白:PB报错: 不能用 DB-Library(如 ISQL)或...

PHP中include与require使用方法区别详解

在PHP变成中,include()与require()的功能相同,include(include_once) 与 require(require_once)都是把把包含的文件代码读入到指...

PHP 7.1中利用OpenSSL代替Mcrypt加解密的方法详解

PHP 7.1中利用OpenSSL代替Mcrypt加解密的方法详解

概要: php7.1发布后新特性吸引了不少PHPer,大家都在讨论新特性带来的好处与便利。但是从php7.0 升级到 php7.1 废弃(过时)了一个在过去普遍应用的扩展(mcrypt...