php 给图片加水印

<?php
    water('upload/images/202007250204199.jpg', 'upload/images/202007250155160.jpg');
    
    function water($durl, $surl) {
        $dit = imagecreatefromjpeg($durl);
        $src = imagecreatefromjpeg($surl);
        
        list($dw, $dh) = getimagesize($durl);
        list($sw, $sh) = getimagesize($surl);
        
        $result = imagecopymerge($dit, $src, ($dw - $sw) / 2, $dh - $sh - 100, 0, 0, $sw, $sh, 100);
        
        header('Content-type:image/jpeg');
        imagejpeg($dit, NULL, 100);
        
        imagedestroy($dit);
        imagedestroy($src);
    }
?>

 

posted @ 2020-07-25 14:13  qiuxd  阅读(131)  评论(0编辑  收藏  举报