php图片水印

<?php
    header('Content-type:image/jpeg');
    $img=imagecreatefromjpeg('images/1.jpg');
    $img2=  imagecreatefromjpeg('images/2.jpg');
    $color= imagecolorallocate($img, 0, 0, 0);
    
    $width=imagesx($img);
    $height=imagesy($img);
    $width2=imagesx($img2);
    $height2=imagesy($img2);
    $position=imagettfbbox(20, 0, 'font/yugang.ttf', '孙捂空');
    $stringwidth=$position[2]-$position[0];
    //  文字水印
    //  imagettftext($img, 14, 0, $width-1-$stringwidth-($width/30), $height-1-($height/30), $color, 'font/yugang.ttf', '孙捂空');
    //  imagecopy($img, $img2, $width-1-$width2, $height-1-$height2, 0, 0, $width2, $height2);不带透明都
    imagecopymerge($img, $img2, $width-1-$width2, $height-1-$height2, 0, 0, $width2, $height2,20);
    imagejpeg($img);
    imagedestroy($img);
?>

 

posted on 2016-09-04 21:25  小胖不胖  阅读(129)  评论(0)    收藏  举报