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+xml实现在线英文词典之添加词条的方法

本文实例讲述了php+xml实现在线英文词典之添加词条的方法。分享给大家供大家参考。具体如下: 接着上一篇《php+xml实现在线英文词典查询的方法》,这里要添加一个功能,提交英文单词和...

PHP5.2下preg_replace函数的问题

preg_replace 使用的超过了php5.2默认允许的字节,也就是pcre.backtrack_limit和pcre.recursion_limit的大小的问题。 Discuz!6...

PHP输出XML到页面的3种方法详解

第一种方法:复制代码 代码如下:<?phpheader("Content-type: text/xml");echo "<?xml version=/"1.0/" encod...

PHP4和PHP5共存于一系统

PHP4和PHP5共存于一系统˂!-- google 的广告条 2005年09月20日换位置 唉,22号被停了.郁闷,没作弊呀 11.27日重开了 ˂!-- googl...

php根据某字段对多维数组进行排序的方法

本文实例讲述了php根据某字段对多维数组进行排序的方法。分享给大家供大家参考。具体分析如下: 根据某字段对多维数组进行排序,在看到array_multisort方法的作用时突然想到,可以...