|
|
@@ -20,7 +20,7 @@ class Image
|
|
|
* @return bool
|
|
|
* @throws
|
|
|
*/
|
|
|
- public function waterMark($filePath, $waterText, $type = 0)
|
|
|
+ public function waterMark($filePath, $waterText, $type = 0, $waterText2 = '')
|
|
|
{
|
|
|
// 1 打开海报背景图
|
|
|
$editor = Grafika::createEditor(['Gd']);
|
|
|
@@ -42,15 +42,12 @@ class Image
|
|
|
$fontSizeArr = $this->get_text_box($waterText, $fontSize, $fontPath);
|
|
|
$fontX = intval(($size[0] * (($hypo - $fontSizeArr[0]) / 2)) / $hypo);
|
|
|
$fontY = $size[1] - intval(($size[1] * (($hypo - $fontSizeArr[0]) / 2)) / $hypo);
|
|
|
-// dump($fontX);
|
|
|
-// dump($fontY);
|
|
|
-// die();
|
|
|
//计算倾斜角度
|
|
|
$angle = intval(atan($size[1] / $size[0]) * 180 / pi());
|
|
|
$image = imagecreatetruecolor($size[0], $size[1]);
|
|
|
} else {
|
|
|
// 判断文字图片开始的位置
|
|
|
- $fontSize = $size[0] / $fontNum ;
|
|
|
+ $fontSize = $size[0] / $fontNum;
|
|
|
// 获取文字大小宽高
|
|
|
$fontSizeArr = $this->get_text_box($waterText, $fontSize, $fontPath);
|
|
|
$fontX = 0;
|
|
|
@@ -68,6 +65,10 @@ class Image
|
|
|
//设置文字颜色
|
|
|
$Color = new Color('#CCCCCC');
|
|
|
$editor->text($fontImage, $waterText, $fontSize, $fontX, $fontY, $Color, $fontPath, $angle);
|
|
|
+ if($waterText2){
|
|
|
+ $editor->text($fontImage, $waterText2, $fontSize, $fontX + $fontSize, $fontY + $fontSize, $Color, $fontPath, $angle);
|
|
|
+ }
|
|
|
+
|
|
|
//合并图片
|
|
|
$editor->blend($backdropImage, $fontImage, 'overlay', 1, 'center');
|
|
|
// 保存图片
|