From: Vincent Vanwaelscappel Date: Wed, 20 Sep 2023 10:36:10 +0000 (+0200) Subject: wait #6273 @0.25 | scan des qr code blancs sur fond foncé X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=14550456405b6020932f60fda3127fcc143fa513;p=fluidbook_tools.git wait #6273 @0.25 | scan des qr code blancs sur fond foncé --- diff --git a/src/Links/Link.php b/src/Links/Link.php index 162ced1..fc68e80 100644 --- a/src/Links/Link.php +++ b/src/Links/Link.php @@ -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; } }