栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

PHP GD库 生成图片水印

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PHP GD库 生成图片水印

* index.php

 'image/jpeg'
// 'mime' => 'image/png'

$a = explode('/', $info['mime']);
$type = array_pop($a);
unset($a);

$dstPath = "tmp.".$type;
call_user_func("image".$type, $dst, $dstPath);
// == 缩略图生成完了 ==

$dstW = $thumbWidth;
$dstH = $thumbHeight;
list($dstW, $dstH) = getimagesize($dstPath);

$src = imagecreatefromstring($dataSrc);

imagecopymerge($dst, $src,
    $dstW - $srcW, $dstH - $srcH,
    0, 0, $srcW, $srcH, 100);



call_user_func("image".$type, $dst, "out.".$type);

imagedestroy($src);
imagedestroy($dst);

* autoload.php

 

* ./lib/Image.php

 0) {
            $width  = $bigWidth * $per;
            $height = $bigHight * $per;
        }

        // 创建缩略图画板
        $block = imagecreatetruecolor($width, $height);

        // 启用混色模式
        imagealphablending($block, false);

        // 保存PNG alpha通道信息
        imagesavealpha($block, true);

        // 创建原图画板
        $bigImg = imagecreatefromstring($imagedata);

        // 缩放
        imagecopyresampled($block, $bigImg, 0, 0, 0, 0,
            $width, $height, $bigWidth, $bigHight);

        // 生成临时文件名
        $tmpFilename = tempnam(sys_get_temp_dir(), 'image_');

        // 保存
        switch ($bigType) {
            case 1: imagegif($block, $tmpFilename);
                break;

            case 2: imagejpeg($block, $tmpFilename);
                break;

            case 3: imagepng($block, $tmpFilename);
                break;
        }

        // 销毁
        imagedestroy($block);

        $image = file_get_contents($tmpFilename);

        unlink($tmpFilename);

        return $image;
    }
}

 

把国旗图片覆盖到目的图片右下角

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/268788.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号