如果要给tp6上传图片之前给图片增加图片水印或者文字水印,必须使用composer安装图像处理类库
安装之后后台的代码逻辑如下:
$files = $_FILES[file];
$name = $files[name];
$format = strrchr($name, .);//截取文件后缀名如 (.jpg)
$file_path = uploads/images/.date(Ymd).“/”.sha1(date(YmdHis, time()) . uniqid()) . $format;//保存路径
$image = \think\Image::open($files[tmp_name])–>text(manongw.com,root_path()./public/static/common/text/simhei.ttf,20,#000000)–>save($file_path); //添加文字水印
$image = \think\Image::open($files[tmp_name])–>water(root_path()./public/static/common/images/water.png,9,80)–>save($file_path); //添加图片水印
是不是很简单?
