php 图片上添加透明度渐变的效果
更新时间:2009年06月29日 23:26:07 作者:
今天因为临时需要,要动态的在图片上添加透明度渐变的效果,在网上找了半天没有相应功能的算法....
复制代码 代码如下:
<?php
////$strimgsrc = file_get_contents("http://127.0.0.1/5307754.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 Class SoapClient not found解决方法
这篇文章主要介绍了PHP Class SoapClient not found解决方法,需要的朋友可以参考下2018-01-01php中base64_decode与base64_encode加密解密函数实例
这篇文章主要介绍了php中base64_decode与base64_encode加密解密函数,实例分析了base64加密解密函数的具体用法,具有一定的实用价值,需要的朋友可以参考下2014-11-11PHP 5.3.1 安装包 VC9 VC6不同版本的区别是什么
php官网提供了四个版本,VC9 x86 Non Thread Safe、VC9 x86 Thread Safe、VC6 x86 Non Thread Safe、VC6 x86 Thread Safe,大家看完这篇文章就知道应该选择什么样的版本了。2010-07-07
最新评论