]> _ Git - fluidbook_tools.git/commitdiff
wait #6273 @0.25 | scan des qr code blancs sur fond foncé
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Sep 2023 10:36:10 +0000 (12:36 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Sep 2023 10:36:10 +0000 (12:36 +0200)
src/Links/Link.php

index 162ced144c96fe4fcc1b4ada7b65d8ff20024788..fc68e8091ee523215623fafe69fb89ad190447aa 100644 (file)
@@ -926,6 +926,7 @@ class Link
     {
 
         $zooms = [1, 2, 4, 6, 8, 10, 12, 14, 16];
+        $types = ['normal', 'invert'];
 
         foreach ($zooms as $zoom) {
             $image = ZoomLink::generateImage([
@@ -943,18 +944,28 @@ class Link
             ], $compiler, 'qrcodereader', 'qrcode', false, false);
 
 
-            $res = Cache::rememberForever('qrcode_' . hash('sha256', $image), function () use ($image) {
-                try {
-                    $result = (new QRCode)->readFromFile($image);
-                    $stringRes = (string)$result;
-                    return $stringRes;
-                } catch (\Exception $e) {
+            foreach ($types as $type) {
+                if ($type === 'invert') {
+                    $invert = str_replace('.jpg', '.invert.jpg', $image);
+                    `convert $image -channel RGB -negate $invert`;
+                    $toscan = $invert;
+                } else {
+                    $toscan = $image;
+                }
+
+                $res = Cache::rememberForever('qrcode_' . hash('sha256', $toscan), function () use ($toscan) {
+                    try {
+                        $result = (new QRCode)->readFromFile($toscan);
+                        $stringRes = (string)$result;
+                        return $stringRes;
+                    } catch (\Exception $e) {
 
+                    }
+                    return '';
+                });
+                if ($res) {
+                    return $res;
                 }
-                return '';
-            });
-            if ($res) {
-                return $res;
             }
         }