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在字符串中查找另一个字符串

<a href="./">返回列表</a><br> <form action="<?echo $PHP_SELF;?>" metho...

php 生成唯一id的几种解决方法

网上查了下,有很多的方法 1、md5(time() . mt_rand(1,1000000));   这种方法有一定的概率会出现重复 2、php内置函数uniqid()   uniqid...

php将从数据库中获得的数据转换成json格式并输出的方法

如下所示: header('content-type:application/json;charset=utf8'); $results = array(); while ($...

基于PHP实现假装商品限时抢购繁忙的效果

最近要做一个项目,有关商品显示抢购的功能。比如我们的网站很带流量,那么成千上万的用户在几秒内同时点你的商品,确实会出现“抢购人数过多,会提示,系统繁忙。   &nbs...

PHP下用rmdir实现删除目录的三种方法小结

1、递规法:利用递归一层一层的删。 复制代码 代码如下:deleteDir($dir)   {   if (rmdir($di...