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数组随机排序实现方法。分享给大家供大家参考。具体实现方法如下: <?php $array = array('A','2','3','4','5',...

PHP连接access数据库

复制代码 代码如下:<?PHP /*    创建ADO连接 */ $conn = @new COM("ADODB.Con...

PHP7新功能总结

以下是小编给大家整理的关于PHP7的相关更新内容和知识点。 新功能 PHP 7增加了许多特性,其中最重要的特性如下所述 • 性能改进——在PHP7中合并了PHPNG代码,速度...

解决file_get_contents无法请求https连接的方法

错误: Warning: fopen() [function.fopen]: Unable to find the wrapper "https" - did you forget to...

PHP实现json_decode不转义中文的方法

本文实例讲述了PHP实现json_decode不转义中文的方法。分享给大家供大家参考,具体如下: 默认情况下PHP的 json_decode 方法会把特殊字符进行转义,还会把中文转为Un...