PHP开发实例大全(提高卷) 中文完整pdf扫描版[244MB]
public function water(){
header("content-type:image/jpg");
import('ORG.Util.Image');
$Image = new Image();
$Image->water('./public/upload/b.jpg','./public/upload/2.jpg',1);
}
这里的路径不能写成__ROOT__/public/upload/b.jpg
./表示当前项目的入口文件
这里扩展了打水印的位置,
switch($position)
{
case 9://9为底端居右
$posX = $ground_w - $w;
$posY = $ground_h - $h;
break;
case 0://随机
$posX = rand(0,($ground_w - $w));
$posY = rand(0,($ground_h - $h));
break;
case 1://1为顶端居左
$posX = 0;
$posY = 0;
break;
case 2://2为顶端居中
$posX = ($ground_w - $w) / 2;
$posY = 0;
break;
case 3://3为顶端居右
$posX = $ground_w - $w;
$posY = 0;
break;
case 4://4为中部居左
$posX = 0;
$posY = ($ground_h - $h) / 2;
break;
case 5://5为中部居中
$posX = ($ground_w - $w) / 2;
$posY = ($ground_h - $h) / 2;
break;
case 6://6为中部居右
$posX = $ground_w - $w;
$posY = ($ground_h - $h) / 2;
break;
case 7://7为底端居左
$posX = 0;
$posY = $ground_h - $h;
break;
case 8://8为底端居中
$posX = ($ground_w - $w) / 2;
$posY = $ground_h - $h;
break;
default://随机位置
$posX = rand(0,($ground_w - $w));
$posY = rand(0,($ground_h - $h));
break;
}
在官方源码的基础上做的改进
转载请注明:谷谷点程序 » thinkphp给图片加水印的方法