🔧 fix QRGdImage::checkGD() to not throw when using default or custom output

This commit is contained in:
smiley
2023-09-08 19:53:37 +02:00
parent af284bfb53
commit 502dd697f5
+14 -7
View File
@@ -81,14 +81,21 @@ class QRGdImage extends QROutputAbstract{
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));