|
16 | 16 | use chillerlan\Settings\SettingsContainerInterface;
|
17 | 17 | use ErrorException;
|
18 | 18 | 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, |
20 | 20 | 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, |
22 | 22 | restore_error_handler, set_error_handler, sprintf;
|
| 23 | +use const IMG_BMP, IMG_GIF, IMG_JPG, IMG_PNG, IMG_WEBP; |
23 | 24 |
|
24 | 25 | /**
|
25 | 26 | * Converts the matrix into GD images, raw or base64 output (requires ext-gd)
|
@@ -90,22 +91,21 @@ protected function checkGD():void{
|
90 | 91 | }
|
91 | 92 |
|
92 | 93 | $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, |
98 | 99 | ];
|
99 | 100 |
|
100 | 101 | // likely using default or custom output
|
101 | 102 | if(!isset($modes[$this->options->outputType])){
|
102 | 103 | return;
|
103 | 104 | }
|
104 | 105 |
|
105 |
| - $info = gd_info(); |
106 | 106 | $mode = $modes[$this->options->outputType];
|
107 | 107 |
|
108 |
| - if(!isset($info[$mode]) || $info[$mode] !== true){ |
| 108 | + if((imagetypes() & $mode) !== $mode){ |
109 | 109 | throw new QRCodeOutputException(sprintf('output mode "%s" not supported', $this->options->outputType));
|
110 | 110 | }
|
111 | 111 |
|
|
0 commit comments