1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > ThinkPHP打水印及设置水印位置办法(实例分析)

ThinkPHP打水印及设置水印位置办法(实例分析)

时间:2020-09-14 05:58:26

相关推荐

ThinkPHP打水印及设置水印位置办法(实例分析)

后端开发|php教程

ThinkPHP,php,位置

后端开发-php教程最近在用Thinkphp的打水印的功能,发现只能打在左下角。 PHP打水印功还是很容易的,最要是用到

dede tag源码,vscode与mysql,ubuntu换源成清华源,tomcat 固定ip,sqlite3 释放,织梦制作插件教程视频,最简洁的前端框架,销量爬虫软件排名,php ueditor,深圳seo云哥seo顾问,商城网站模板后台,网页转手机版 css,软件企业网站模板,php 页面统计,电脑设备管理系统破解版,小程序源码与微擎框架结合lzw

复制代码 代码如下:

rdesktop源码分析,vscode开发vsto,ubuntu更新后无法登陆,tomcat内存文件,koa sqlite3,windows窗口插件,layui配合哪个前端框架,网络爬虫中的htlm,php 项目 视频,seo站内优化怎么做seo博客,实用网站小源码,网页制作手表代码,起点小说模板,微信小程序机票源码lzw

bool imagecopymerge ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct )

php自动发卡平台源码,ubuntu网卡没ip,tomcat提示未安装上,Python爬虫行业,php隐藏源代码,黔江区智能化seo推广代运营lzw

将 src_im 图像中坐标从 src_x,src_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_x 和 dst_y 的位置上。两图像将根据 pct 来决定合并程度,其值范围从 0 到 100。当 pct = 0 时,实际上什么也没做,当为 100 时对于调色板图像本函数和 imagecopy() 完全一样,它对真彩色图像实现了 alpha 透明。

水印demo图:

我需要把水印打到图片的真中间,查看Thinkphp代码。发现,作者居然是写死了,我只能做一个修改

/*** 为图片添加水印* @static public* @param string $source 原文件名* @param string $water 水印图片* @param string $$savename 添加水印后的图片名* @param string $postion 水印的具体位置 leftbottom rightbottom lefttop righttop center * @param string $alpha 水印的透明度* @return void*/static public function water($source, $water, $savename=null,$postion="center", $alpha=80) {//检查文件是否存在if (!file_exists($source) || !file_exists($water))return false;//图片信息$sInfo = self::getImageInfo($source);$wInfo = self::getImageInfo($water);//如果图片小于水印图片,不生成图片if ($sInfo["width"] < $wInfo["width"] || $sInfo[height] WaterPostion($postion,$sInfo,$wInfo); //新增 //生成混合图像 imagecopymerge($sImage, $wImage, $posArr[0], $posArr[1], 0, 0, $wInfo[width], $wInfo[height], $alpha); //输出图像 $ImageFun = Image . $sInfo[ ype]; //如果没有给出保存文件名,默认为原图像名 if (!$savename) { $savename = $source; @unlink($source); } //保存图像 $ImageFun($sImage, $savename); imagedestroy($sImage); } private function WaterPostion($postion,$sInfo,$wInfo) { $posY = $sInfo["height"] - $wInfo["height"]; $posX = $sInfo["width"] - $wInfo["width"]; switch($postion) { case "rightbottom": return array($posX,$posY); break; case "leftbottom": return array($wInfo["width"],$posY); break; case "lefttop": return array($wInfo["width"],$wInfo["height"]); break; case "righttop": return array($posX,$wInfo["height"]); break; case "center": return array($posX/2,$posY/2); break; }}

总结:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。