Skip to content

Commit 502dd69

Browse files
committed
🔧 fix QRGdImage::checkGD() to not throw when using default or custom output
1 parent af284bf commit 502dd69

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Output/QRGdImage.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,21 @@ protected function checkGD():void{
8181
throw new QRCodeOutputException('ext-gd not loaded');
8282
}
8383

84+
$modes = [
85+
self::GDIMAGE_BMP => 'BMP Support',
86+
self::GDIMAGE_GIF => 'GIF Create Support',
87+
self::GDIMAGE_JPG => 'JPEG Support',
88+
self::GDIMAGE_PNG => 'PNG Support',
89+
self::GDIMAGE_WEBP => 'WebP Support',
90+
];
91+
92+
// likely using default or custom output
93+
if(!isset($modes[$this->options->outputType])){
94+
return;
95+
}
96+
8497
$info = gd_info();
85-
$mode = [
86-
self::GDIMAGE_BMP => 'BMP Support',
87-
self::GDIMAGE_GIF => 'GIF Create Support',
88-
self::GDIMAGE_JPG => 'JPEG Support',
89-
self::GDIMAGE_PNG => 'PNG Support',
90-
self::GDIMAGE_WEBP => 'WebP Support',
91-
][$this->options->outputType];
98+
$mode = $modes[$this->options->outputType];
9299

93100
if(!isset($info[$mode]) || $info[$mode] !== true){
94101
throw new QRCodeOutputException(sprintf('output mode "%s" not supported', $this->options->outputType));

0 commit comments

Comments
 (0)