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面向对象之多态

什么是多态性? 多态性是继数据库抽象和继承后,面向对象语言的第三个特征。多态即多种形态,具有表现多种形态的能力特征。在面向对象中表示根据对象的类型以不同方式处理。多态性允许每个对象以适合...

php快速url重写 更新版[需php 5.30以上]

对于apache的rewrite模块打开和设置则非本文主题,请见其他文章详解. 这个类只能php 5.30以上的版本才能使用,继承了上一个版本的快速重定向的特点(单独类,全部使用静态调用...

功能强大的php文件上传类

本文实例为大家分享了php文件上传类,功能很强大,供大家参考,具体内容如下 <?PHP /* *文件上传类 **/ class upfile{ private $fi...

php5.3 不支持 session_register() 此函数已启用的解决方法

php从5.2.x升级到5.3.2.出来问题了。有些原来能用的程序报错了。报错内容是Deprecated: Function session_register() is deprecat...

smarty巧妙处理iframe中内容页的代码

废话不多说,进去正题 做过后台的,应该都知道,经常要用到iframe来处理导航,如果按一般的思路来做这个功能,还是挺简单的 可是当我用smarty的时候,就发现了问题,比如,一个ifra...