use Cubist\Util\Xml;
use Fluidbook\Tools\Compiler\CompilerInterface;
use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Log;
use SodiumException;
use stdClass;
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 '';
}
-
-
}