From: Vincent Vanwaelscappel Date: Wed, 13 Sep 2023 17:06:54 +0000 (+0200) Subject: wait #6273 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=561ea083d70f90ef2667d2475ffe98ef60c79cd2;p=fluidbook_tools.git wait #6273 @0.5 --- diff --git a/src/Links/Link.php b/src/Links/Link.php index 940efd8..6d1ba21 100644 --- a/src/Links/Link.php +++ b/src/Links/Link.php @@ -14,6 +14,7 @@ use Cubist\Util\Text; use Cubist\Util\Xml; use Fluidbook\Tools\Compiler\CompilerInterface; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Log; use SodiumException; use stdClass; @@ -914,32 +915,40 @@ class Link public static function scanQRCode($link, $compiler) { - $image = ZoomLink::generateImage([ - 'id' => $link['uid'], - 'page' => $link['page'], - 'maxzoom' => 8, - 'group' => '', - 'group-count' => 0, - 'width' => round($link['width']), - 'height' => round($link['height']), - 'x' => round($link['left']), - 'y' => round($link['top']), - 'border' => 0, - 'borderColor' => '', - ], $compiler, 'qrcodereader', 'qrcode', false, false); + $zooms = [1, 2, 4, 8, 16]; + foreach ($zooms as $zoom) { + $image = ZoomLink::generateImage([ + 'id' => $link['uid'], + 'page' => $link['page'], + 'maxzoom' => $zoom, + 'group' => '', + 'group-count' => 0, + 'width' => round($link['width']), + 'height' => round($link['height']), + 'x' => round($link['left']), + 'y' => round($link['top']), + 'border' => 0, + 'borderColor' => '', + ], $compiler, 'qrcodereader', 'qrcode', false, false); - return Cache::rememberForever('qrcode_' . hash('sha256', $image), function () use ($image) { - try { - $result = (new QRCode)->readFromFile($image); - return (string)$result; - } catch (\Exception $e) { + $res = Cache::rememberForever('qrcode_' . hash('sha256', $image), function () use ($image) { + try { + $result = (new QRCode)->readFromFile($image); + $stringRes = (string)$result; + return $stringRes; + } catch (\Exception $e) { + + } + return ''; + }); + if ($res) { + return $res; } - return ''; - }); + } + Log::warning('QRcode not found ' . $link['uid']); + return ''; } - - }