php图片文字水印

<?php
    header('Content-type:image/jpeg');
    $width='';
    $height='';
    $img=imagecreatefromjpeg('images/1.jpg');
    $color= imagecolorallocate($img, 0, 0, 0);
    
    $width=imagesx($img);
    $height=imagesy($img);
    $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', '孙捂空');
    imagejpeg($img);
    imagedestroy($img);
?>

 

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