php图片水印

Posted 小胖不胖

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
?>

 

以上是关于php图片水印的主要内容,如果未能解决你的问题,请参考以下文章