php 图片上添加透明度渐变的效果

时间:2023-10-23 09:00:02 


<?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,图片,透明度,渐变
0
投稿

猜你喜欢

  • Pytest实现setup和teardown的详细使用详解

    2023-09-12 02:06:48
  • 使用Math.max,Math.min获取数组中的最值实例

    2023-09-03 23:23:59
  • python如何基于redis实现ip代理池

    2022-11-05 20:49:08
  • 利用PyQt5模拟实现网页鼠标移动特效

    2022-11-17 10:46:01
  • python使用BeautifulSoup分页网页中超链接的方法

    2023-11-21 07:24:49
  • 【推荐】汉字转为拼音的asp函数

    2007-08-17 11:11:00
  • Go中函数的使用细节与注意事项详解

    2023-10-15 01:02:32
  • 8个asp生成随机字符的函数

    2007-08-04 10:17:00
  • python用什么编辑器进行项目开发

    2021-04-17 19:25:20
  • python中的print()输出

    2023-06-27 18:07:03
  • layui 上传文件_批量导入数据UI的方法

    2024-05-22 10:36:41
  • vue实现小球滑动交叉效果

    2024-04-30 10:30:09
  • Python中如何实现MOOC扫码登录

    2021-10-08 14:24:50
  • 利用Python写个摸鱼监控进程

    2022-11-04 10:40:45
  • 浅谈Webpack自动化构建实践指南

    2024-04-29 13:39:58
  • 详解Python验证码识别

    2023-11-12 23:46:40
  • 一文带你梳理Python的中级知识

    2022-03-13 14:36:29
  • Go 结构体、数组、字典和 json 字符串的相互转换方法

    2024-05-05 09:26:42
  • Python 数据类型--集合set

    2021-11-23 21:17:54
  • JSP实现浏览器关闭cookies情况下的会话管理

    2024-03-27 07:29:10
  • asp之家 网络编程 m.aspxhome.com