Skip to content

Commit e81ed39

Browse files
committed
:octocat: QRGdImage::checkGD(): use imagetypes() instead of gd_info()
1 parent 4526edb commit e81ed39

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Output/QRGdImage.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
use chillerlan\Settings\SettingsContainerInterface;
1717
use ErrorException;
1818
use Throwable;
19-
use function array_values, count, extension_loaded, gd_info, imagebmp, imagecolorallocate, imagecolortransparent,
19+
use function array_values, count, extension_loaded, imagebmp, imagecolorallocate, imagecolortransparent,
2020
imagecreatetruecolor, imagedestroy, imagefilledellipse, imagefilledrectangle, imagegif, imagejpeg, imagepng,
21-
imagescale, imagewebp, intdiv, intval, is_array, is_numeric, max, min, ob_end_clean, ob_get_contents, ob_start,
21+
imagescale, imagetypes, imagewebp, intdiv, intval, is_array, is_numeric, max, min, ob_end_clean, ob_get_contents, ob_start,
2222
restore_error_handler, set_error_handler, sprintf;
23+
use const IMG_BMP, IMG_GIF, IMG_JPG, IMG_PNG, IMG_WEBP;
2324

2425
/**
2526
* Converts the matrix into GD images, raw or base64 output (requires ext-gd)
@@ -90,22 +91,21 @@ protected function checkGD():void{
9091
}
9192

9293
$modes = [
93-
self::GDIMAGE_BMP => 'BMP Support',
94-
self::GDIMAGE_GIF => 'GIF Create Support',
95-
self::GDIMAGE_JPG => 'JPEG Support',
96-
self::GDIMAGE_PNG => 'PNG Support',
97-
self::GDIMAGE_WEBP => 'WebP Support',
94+
self::GDIMAGE_BMP => IMG_BMP,
95+
self::GDIMAGE_GIF => IMG_GIF,
96+
self::GDIMAGE_JPG => IMG_JPG,
97+
self::GDIMAGE_PNG => IMG_PNG,
98+
self::GDIMAGE_WEBP => IMG_WEBP,
9899
];
99100

100101
// likely using default or custom output
101102
if(!isset($modes[$this->options->outputType])){
102103
return;
103104
}
104105

105-
$info = gd_info();
106106
$mode = $modes[$this->options->outputType];
107107

108-
if(!isset($info[$mode]) || $info[$mode] !== true){
108+
if((imagetypes() & $mode) !== $mode){
109109
throw new QRCodeOutputException(sprintf('output mode "%s" not supported', $this->options->outputType));
110110
}
111111

0 commit comments

Comments
 (0)