|
...
|
...
|
@@ -171,7 +171,7 @@ class CosService |
|
|
|
public function addFieldImage($cdnUrl = '',$data = [],$is_image = false){
|
|
|
|
if($is_image){
|
|
|
|
$param = [
|
|
|
|
'image/'.urlencode(base64_encode("{$data['image']}")),//文字水印名称
|
|
|
|
'image/'.urlSafeBase64Encode($data['image']),//文字水印名称
|
|
|
|
$data['position'] ?? 'gravity/SouthEast',
|
|
|
|
$data['dx'] ?? 'dx/10/dy/10',
|
|
|
|
$data['font'] ?? 'font/5bCP6aOe',//默认宋体
|
|
...
|
...
|
@@ -181,7 +181,7 @@ class CosService |
|
|
|
$cdnUrl = $cdnUrl.'?imageMogr2/watermark/1/'.implode('/',$param);
|
|
|
|
}else{
|
|
|
|
$param = [
|
|
|
|
'text/'.urlencode(base64_encode("{$data['characters']}")),//文字水印名称
|
|
|
|
'text/'.urlSafeBase64Encode($data['characters']),//文字水印名称
|
|
|
|
$data['position'] ?? 'gravity/SouthEast',
|
|
|
|
$data['dx'] ?? 'dx/10/dy/10',
|
|
|
|
$data['font'] ?? 'font/5bCP6aOe',//默认宋体
|
|
...
|
...
|
@@ -192,4 +192,23 @@ class CosService |
|
|
|
}
|
|
|
|
return $cdnUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :腾讯云安全的base64
|
|
|
|
* @name :urlSafeBase64Encode
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/19 14:21
|
|
|
|
*/
|
|
|
|
public function urlSafeBase64Encode($data) {
|
|
|
|
// 1. 使用标准的 BASE64 编码
|
|
|
|
$base64 = base64_encode($data);
|
|
|
|
// 2. 将加号(+)替换成连接号(-)
|
|
|
|
$base64 = str_replace('+', '-', $base64);
|
|
|
|
// 3. 将正斜线(/)替换成下划线(_)
|
|
|
|
$base64 = str_replace('/', '_', $base64);
|
|
|
|
// 4. 去掉末尾的等号(=)
|
|
|
|
$base64 = rtrim($base64, '=');
|
|
|
|
return $base64;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|