Blogger Information
Blog 26
fans 1
comment 1
visits 35449
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php 图像处理
Bystander
Original
1312 people have browsed it
  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);   // 保存

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post