为图片添加文字水印

 1 <?php
 2 $filename="des_big.jpg";
 3 $fileInfo=getimagesize($filename);
 4 //echo $fileInfo;  echo "<br>";
 5 $mime=$fileInfo['mime']; 
 6 //echo $mime; echo "<br>";
 7 $createFun=str_replace("/","createfrom",$mime);
 8 //echo $createFun; echo "<br>";
 9 $outFun=str_replace("/",null,$mime);
10 $image=$createFun($filename);
11 //echo $image; echo "<br>";
12 $color=imagecolorallocatealpha($image,255,0,0,50);
13 $fontfile="../fonts/h.ttf";
14 $text="imooc.com";
15 imagettftext($image,14,0,0,14,$color,$fontfile,$text);
16 //header("content-type:".$mime);
17 $outFun($image,$filename);
18 imagedestroy($image);
19 echo "<img src='$filename'>";
20 ?>
21  

 

posted @ 2015-01-28 10:49  todaytoday  阅读(259)  评论(0编辑  收藏  举报