<tfoot id='WoOXF'></tfoot>
  1. <legend id='WoOXF'><style id='WoOXF'><dir id='WoOXF'><q id='WoOXF'></q></dir></style></legend>

      <small id='WoOXF'></small><noframes id='WoOXF'>

      <i id='WoOXF'><tr id='WoOXF'><dt id='WoOXF'><q id='WoOXF'><span id='WoOXF'><b id='WoOXF'><form id='WoOXF'><ins id='WoOXF'></ins><ul id='WoOXF'></ul><sub id='WoOXF'></sub></form><legend id='WoOXF'></legend><bdo id='WoOXF'><pre id='WoOXF'><center id='WoOXF'></center></pre></bdo></b><th id='WoOXF'></th></span></q></dt></tr></i><div id='WoOXF'><tfoot id='WoOXF'></tfoot><dl id='WoOXF'><fieldset id='WoOXF'></fieldset></dl></div>
        <bdo id='WoOXF'></bdo><ul id='WoOXF'></ul>

      PHP实现图片加水印实例代码(平铺水印+倾斜水印)

      时间:2024-08-28
    1. <small id='15Lao'></small><noframes id='15Lao'>

      <tfoot id='15Lao'></tfoot>
        <tbody id='15Lao'></tbody>
          <bdo id='15Lao'></bdo><ul id='15Lao'></ul>

            • <i id='15Lao'><tr id='15Lao'><dt id='15Lao'><q id='15Lao'><span id='15Lao'><b id='15Lao'><form id='15Lao'><ins id='15Lao'></ins><ul id='15Lao'></ul><sub id='15Lao'></sub></form><legend id='15Lao'></legend><bdo id='15Lao'><pre id='15Lao'><center id='15Lao'></center></pre></bdo></b><th id='15Lao'></th></span></q></dt></tr></i><div id='15Lao'><tfoot id='15Lao'></tfoot><dl id='15Lao'><fieldset id='15Lao'></fieldset></dl></div>

              <legend id='15Lao'><style id='15Lao'><dir id='15Lao'><q id='15Lao'></q></dir></style></legend>

                PHP实现图片加水印代码,具体代码如下:
                //$img => 图片,$source => 水印
                    $img = 'test.jpg';
                    $source = 'source.png';
                
                    //参数设置,值越大水印越稀(水印平铺的越少),相反...
                    $ww = 0;  //每个水印的左右间距
                    $hh = 0;  //每个水印的上下间距
                
                    //水印图片旋转角度
                    $angle = 30;
                
                    //水印透明度
                    $opacity = 20;
                
                    //获取图片和水印的信息
                    $imgInfo = getimagesize($img);
                    $sourceInfo = getimagesize($source);
                
                    //创建水印图像资源
                    $fun   = 'imagecreatefrom' . image_type_to_extension($sourceInfo[2], false);
                    $water = $fun($source);
                    //水印图片旋转
                    $water = imagerotate($water,$angle, imageColorAllocateAlpha($water, 0, 0, 0, 127));
                    //获取水印图片旋转后的宽度和高度
                    $sourceInfo[0] = imagesx($water);
                    $sourceInfo[1] = imagesy($water);
                
                    //设定水印图像的混色模式
                    imagealphablending($water, true);
                    //添加水印
                    $src = imagecreatetruecolor($sourceInfo[0], $sourceInfo[1]);
                    // 调整默认颜色
                    $color = imagecolorallocate($src, 255, 255, 255);
                    imagefill($src, 0, 0, $color);
                
                    //创建图片图像资源
                    $fun   = 'imagecreatefrom' . image_type_to_extension($imgInfo[2], false);
                    $thumb = $fun($img);
                
                    //定义平铺数据
                    $x_length = $imgInfo[0] - 10; //x轴总长度
                    $y_length = $imgInfo[1] - 10; //y轴总长度
                    //循环平铺水印
                    for ($x = 0; $x < $x_length; $x) {
                        for ($y = 0; $y < $y_length; $y) {
                            imagecopy($src, $thumb, 0, 0, $x, $y, $sourceInfo[0], $sourceInfo[1]);
                            imagecopy($src, $water, 0, 0, 0, 0, $sourceInfo[0], $sourceInfo[1]);
                            imagecopymerge($thumb, $src, $x, $y, 0, 0, $sourceInfo[0], $sourceInfo[1], $opacity);
                            $y += $sourceInfo[1] + $hh;
                        }
                        $x += $sourceInfo[0] + $ww;
                    }
                
                    header("Content-type:image/jpeg");
                    imagejpeg($thumb);
                
                    //销毁零时图片资源
                    imagedestroy($src);
                    //销毁水印资源
                    imagedestroy($water);
                最终实现效果如下:
                上一篇:layui实现上传图片并自定义截取(含php后端代码) 下一篇:没有了

                相关文章

                <small id='7bsHo'></small><noframes id='7bsHo'>

                • <bdo id='7bsHo'></bdo><ul id='7bsHo'></ul>

                  1. <i id='7bsHo'><tr id='7bsHo'><dt id='7bsHo'><q id='7bsHo'><span id='7bsHo'><b id='7bsHo'><form id='7bsHo'><ins id='7bsHo'></ins><ul id='7bsHo'></ul><sub id='7bsHo'></sub></form><legend id='7bsHo'></legend><bdo id='7bsHo'><pre id='7bsHo'><center id='7bsHo'></center></pre></bdo></b><th id='7bsHo'></th></span></q></dt></tr></i><div id='7bsHo'><tfoot id='7bsHo'></tfoot><dl id='7bsHo'><fieldset id='7bsHo'></fieldset></dl></div>

                    <legend id='7bsHo'><style id='7bsHo'><dir id='7bsHo'><q id='7bsHo'></q></dir></style></legend>

                    <tfoot id='7bsHo'></tfoot>