• 技术文章 >后端开发 >php教程

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

    2016-05-17 09:31:42原创386
    复制代码 代码如下:

    ////$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);
    ?>
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:php 图片 透明度 渐变
    上一篇:php 过滤危险html代码_php技巧 下一篇:PHP 多进程 解决难题_php技巧
    千万级数据并发解决方案

    相关文章推荐

    • ThinkPHP实现将SESSION存入MYSQL的方法_PHP• php中实现精确设置session过期时间的方法_PHP• CodeIgniter安全相关设置汇总_PHP• PHP+Mysql+Ajax+JS实现省市区三级联动_PHP• php实现批量下载百度云盘文件例子分享_PHP
    1/1

    PHP中文网