登录  /  注册
博主信息
博文 26
粉丝 1
评论 1
访问量 34508
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
php 图像处理
Bystander
原创
1292人浏览过
  1. 打水印  实例

    function sy($dst_path,$src_path,$newcopy)
    {
        //创建图片的实例
        $dst = imagecreatefromstring(file_get_contents($dst_path));
        $src = imagecreatefromstring(file_get_contents($src_path));
        //获取水印图片的宽高
        list($src_w, $src_h) = getimagesize($src_path);

        //将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果
        // imagecopymerge($dst, $src, 10, 10, 70,0, $src_w, $src_h,20);
        //如果水印图片本身带透明色,则使用imagecopy方法
        imagecopy($dst, $src, 100, 150, 0, 0, $src_w, $src_h);
        //输出图片
        // list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
        // switch ($dst_type) {
        //     case 1://GIF
        //         header('Content-Type: image/gif');
        //         imagegif($dst);
        //         break;
        //     case 2://JPG
        //         header('Content-Type: image/jpeg');
        //         imagejpeg($dst);
        //         break;
        //     case 3://PNG
        //         header('Content-Type: image/png');
        //         imagepng($dst);
        //         break;
        //     default:
        //         break;
        // }

        // var_dump($dst);exit;
        imagejpeg($dst, $newcopy, 100); // 保存图片
    }

  2. 马赛克 实例

    function imagemask(&$im, $x1, $y1, $x2, $y2, $deep)
    {
        for($x = $x1; $x < $x2; $x += $deep){
            for ($y = $y1; $y < $y2; $y += $deep){
                $color = imagecolorat ($im, $x + round($deep / 2), $y + round($deep / 2));
                imagefilledrectangle ($im, $x, $y, $x + $deep, $y + $deep, $color);
            }
        }
    }

调用方法:

       $im = imagecreatefromjpeg($res2);  // res2 图片
        imagemask($im, 70, 30, 140, 40, 8);
        imagejpeg($im,$urlpath);   // 保存

本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学