tp6 给图片添加图标、文字水印

2025-11-07 0 123

如果要给tp6上传图片之前给图片增加图片水印或者文字水印,必须使用composer安装图像处理类库

composer require topthink/thinkimage

安装之后后台的代码逻辑如下:

$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); //添加图片水印

是不是很简单?

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

遇见资源网 后端开发 tp6 给图片添加图标、文字水印 https://www.ox520.com/4417.html

常见问题

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务