dever %!s(int64=3) %!d(string=hai) anos
pai
achega
2e6009bb39
Modificáronse 3 ficheiros con 54 adicións e 11 borrados
  1. 22 5
      database/pic_water.php
  2. 2 0
      lib/Store/Local.php
  3. 30 6
      lib/Store/Qiniu.php

+ 22 - 5
database/pic_water.php

@@ -4,10 +4,10 @@
  */
  
 # 定义几个常用的选项
-$option = array
+$type = array
 (
-	1 => '启用',
-	2 => '关闭',
+	1 => '图片水印',
+	//2 => '文字水印',
 );
 
 $water = array
@@ -19,6 +19,9 @@ $water = array
 	5 => '居中',
 	6 => '上中',
 	7 => '下中',
+	8 => '左中',
+	9 => '右中',
+	10 => '平铺',
 );
 
 return array
@@ -53,6 +56,19 @@ return array
 			'search'	=> 'fulltext',
 			'list'		=> true,
 		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '水印类型',
+			'default' 	=> '1',
+			'desc' 		=> '水印类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			'list'		=> true,
+			'control'	=> 'type',
+		),
 		
 		'water'		=> array
 		(
@@ -64,14 +80,15 @@ return array
 			'update'	=> 'image',
 			'key' 		=> '1',
 			'place'		=> '150X150',
+			'show'		=> 'type=1',
 		),
 		
 		'water_position'		=> array
 		(
 			'type' 		=> 'int-1',
-			'name' 		=> '水印位置',
+			'name' 		=> '水印位置',
 			'default' 	=> '1',
-			'desc' 		=> '请选择水印位置',
+			'desc' 		=> '请选择水印位置',
 			'match' 	=> 'is_numeric',
 			'option' 	=> $water,
 			'update'	=> 'select',

+ 2 - 0
lib/Store/Local.php

@@ -90,6 +90,8 @@ class Local extends Core implements Config
 			$water = array('water'=> $config['water'], 'position'=> ($config['water_position'] ? $config['water_position'] : 1));
 			
             $this->img()->mark($this->output['file'], $water, true, $this->file());
+
+            Dever::config('base')->handle_w = $this->output['file'];
 		}
 	}
 

+ 30 - 6
lib/Store/Qiniu.php

@@ -68,15 +68,39 @@ class Qiniu extends Core implements Config
      * 
      * @return mixed
      */
-    public function handle_w($id)
+    public function handle_w($id, $source = false)
     {
         $config = Dever::load('upload/pic_water-one', $id);
         if ($config) {
-            $this->name .= '_w' . $id;
-            
-            $water = array('water'=> $config['water'], 'position'=> ($config['water_position'] ? $config['water_position'] : 1));
-            
-            $this->img()->mark($this->output['file'], $water, true, $this->file());
+            if (isset(Dever::config('base')->handle_w) && Dever::config('base')->handle_w) {
+                # 走本地水印
+                list($yun, $file) = $this->yun();
+                $this->name .= '_w' . $id;
+                $file = $this->file();
+                $options = array();
+                Dever::load('upload/lib/view/qiniu')->connect($yun, $this->config, $file)->upload($file, Dever::config('base')->handle_w, $options);
+            } else {
+                # 走七牛的水印
+                # 参考:https://developer.qiniu.com/dora/1316/image-watermarking-processing-watermark
+                # 暂时未实现
+                return;
+                if (!$source) {
+                    $source = $this->output['file'];
+                }
+
+                //?imageView2/2/w/360/h/270/format/png/q/75|imageslim
+                if (!strstr($source, 'http')) {
+                    $source = $this->data['host'] . $source;
+                }
+                if (strstr($source, '?')) {
+                    $prefix = '&';
+                } else {
+                    $prefix = '?';
+                }
+                $dest = $source . $prefix . 'watermark/1/image/a29kbzovL2RldmVsb3Blci1kb2N1bWVudHMtaW1hZ2UvcWluaXV5dW4ucG5n/dissolve/50/gravity/SouthEast/dx/20/dy/20/ws/0.2';
+
+                $dest .= '|imageslim';
+            }
         }
     }