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给图片添加文字水印方法汇总

1: 面向过程的编写方法 //指定图片路径 $src = '001.png'; //获取图片信息 $info = getimagesize($src); //获取图片扩展名 $typ...

php中将时间差转换为字符串提示的实现代码

如微博 这看起来更加人性化,好吧,上代码 复制代码 代码如下: <?php class timeAgo { static $timeagoObject; private $rust...

PHP微信开发之微信录音临时转永久存储

最近做开发的时候碰到了这个问题,甲方希望用户在微信端的录音能够一直有效。就是随时打开好友的分享就能听到好友的录音。可在微信官方开发手册上查到微信录音文件上传后只能在微信端保留3天时间,3...

PHP 金额数字转换成英文

复制代码 代码如下:<?php $num=1220.01; echo fmoney($num);//结果:1,220.21 echo umoney($num); //结果:ONE...

php判断文件上传图片格式的实例详解

php判断文件上传图片格式的实例详解 判断文件图片类型, $type = $_FILES['image']['tmp_name'];//文件名 //$type = $this...