From 502dd697f5c29eb25f210e1b4331199d278e7d34 Mon Sep 17 00:00:00 2001 From: smiley Date: Fri, 8 Sep 2023 19:53:37 +0200 Subject: [PATCH] :wrench: fix QRGdImage::checkGD() to not throw when using default or custom output --- src/Output/QRGdImage.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Output/QRGdImage.php b/src/Output/QRGdImage.php index 355bc33a1..9a0b5b24e 100644 --- a/src/Output/QRGdImage.php +++ b/src/Output/QRGdImage.php @@ -81,14 +81,21 @@ protected function checkGD():void{ throw new QRCodeOutputException('ext-gd not loaded'); } + $modes = [ + self::GDIMAGE_BMP => 'BMP Support', + self::GDIMAGE_GIF => 'GIF Create Support', + self::GDIMAGE_JPG => 'JPEG Support', + self::GDIMAGE_PNG => 'PNG Support', + self::GDIMAGE_WEBP => 'WebP Support', + ]; + + // likely using default or custom output + if(!isset($modes[$this->options->outputType])){ + return; + } + $info = gd_info(); - $mode = [ - self::GDIMAGE_BMP => 'BMP Support', - self::GDIMAGE_GIF => 'GIF Create Support', - self::GDIMAGE_JPG => 'JPEG Support', - self::GDIMAGE_PNG => 'PNG Support', - self::GDIMAGE_WEBP => 'WebP Support', - ][$this->options->outputType]; + $mode = $modes[$this->options->outputType]; if(!isset($info[$mode]) || $info[$mode] !== true){ throw new QRCodeOutputException(sprintf('output mode "%s" not supported', $this->options->outputType));