当前位置:   article > 正文

php 生成水印图片_php img_water_mark

php img_water_mark
//图片水印
function img_water_mark()
{
    $dst_path = '011.jpg';
    $src_path = 'dianchao.png';
    $new_img_name = '012.jpg';
    //创建图片的实例
    $dst = imagecreatefromstring(file_get_contents($dst_path));
    $src = imagecreatefromstring(file_get_contents($src_path));
    //获取水印图片的宽高
    list($src_w, $src_h) = getimagesize($src_path);
    //获取原图的宽高
    list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
    //将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果
    $pos=2;
    /*
     * 10种水印效果位置
     * 0:默认是随机位置
     * 1:顶端居左
     * 2:顶端居中
     * 3:顶端居右
     * 4:中部居左
     * 5:中部居中
     * 6:中部居右
     * 7:底端居左
     * 8:底端居中
     * 9:底端居右
     */
    switch ($pos) {
        case 0:
            $pos_x = rand(0, ($dst_w - $src_w));
            $pos_y = rand(0, ($dst_h - $src_h));
            break;

        case 1:
            $pos_x = 0;
      
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/326050
推荐阅读
  

闽ICP备14008679号