PHP GD库

 

<?php
    $file = '12.jpg'; 
    //打开图片
    $im = imagecreatefromjpeg($file);
    //设置水印字体颜色
    $color = imagecolorallocatealpha($im,211,210,212,80);
    //设置字体文件路径
    $fontfile = "./msyhbd.ttf";
    //水印文字
    $str = iconv("gbk","utf-8","长沙源码PHP培训");
    //打水印
    imagettftext($im,30,0,40,80,$color,$fontfile,$str);
    header("content-type:image/jpeg");
    imagejpeg($im);
    imagejpeg($im,'water.jpg');
    imagedestroy($im);
?>