首页 > 代码库 > 为图片添加文字水印

为图片添加文字水印

<?php$filename="des_big.jpg";$fileInfo=getimagesize($filename);//echo $fileInfo;  echo "<br>";$mime=$fileInfo[‘mime‘]; //echo $mime; echo "<br>";$createFun=str_replace("/","createfrom",$mime);//echo $createFun; echo "<br>";$outFun=str_replace("/",null,$mime);$image=$createFun($filename);//echo $image; echo "<br>";$color=imagecolorallocatealpha($image,255,0,0,50);$fontfile="../fonts/h.ttf";$text="imooc.com";imagettftext($image,14,0,0,14,$color,$fontfile,$text);//header("content-type:".$mime);$outFun($image,$filename);imagedestroy($image);echo "<img src=http://www.mamicode.com/‘$filename‘>";?>

 

为图片添加文字水印