wesmiler 6 лет назад
Родитель
Сommit
796e82a5ae

+ 5 - 3
vendor/thinkcmf/cmf-app/src/weixin/controller/TestController.php

@@ -34,9 +34,11 @@ class TestController extends HomeBaseController
     public function filterColor()
     {
         $file = 'print/20200309/2e86ce9dd6a1ea9fef2a035121a122fb.jpeg';
-        $file = Stroage::filtterColor($file);
-        echo "<img src='/upload/{$file}'>";
-        echo "<img src='/upload/{$file}'>";
+        echo '<div style="background: #000000;width: 100%; ">';
+        echo "<img src='/upload/{$file}' width='360' height='480'>";
+        $file = Stroage::filtterColor($file, 2);
+        echo "<img src='/upload/{$file}' width='360' height='480' style='margin-left: 10px;'>";
+        echo '</div>';
     }
 
     public function qrcode(){

+ 4 - 2
vendor/thinkcmf/cmf-app/src/weixin/model/Stroage.php

@@ -313,7 +313,7 @@ class Stroage extends Model
      * @param $file
      * @return string
      */
-    public static function filtterColor($file)
+    public static function filtterColor($file, $type=1, $light=6)
     {
         $filepath = dirname($file);
         $newFile = $filepath . '/color_' . basename($file);
@@ -323,7 +323,9 @@ class Stroage extends Model
 
         @fopen('upload/' . $newFile, 'w+');
         $im = imagecreatefromjpeg('upload/' . $file);
-        if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) {
+        if ($im && imagefilter($im, 1)) {
+            imagefilter($im, 2, $light);
+//            imagefilter($im, 4, 0,0,0);
             imagepng($im, 'upload/' . $newFile);
         } else {
             $newFile = '';