|
16 | 16 | use chillerlan\QRCode\Data\QRMatrix;
|
17 | 17 | use chillerlan\Settings\SettingsContainerInterface;
|
18 | 18 | use ErrorException, GdImage, Throwable;
|
19 |
| -use function array_values, count, extension_loaded, gd_info, imagecolorallocate, imagecolortransparent, |
| 19 | +use function array_values, count, extension_loaded, imagecolorallocate, imagecolortransparent, |
20 | 20 | imagecreatetruecolor, imagedestroy, imagefilledellipse, imagefilledrectangle,
|
21 |
| - imagescale, intdiv, intval, is_array, is_numeric, max, min, ob_end_clean, ob_get_contents, ob_start, |
| 21 | + imagescale, imagetypes, 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_AVIF, 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)
|
@@ -83,23 +84,22 @@ protected function checkGD():void{
|
83 | 84 | }
|
84 | 85 |
|
85 | 86 | $modes = [
|
86 |
| - QRGdImageAVIF::class => 'AVIF Support', |
87 |
| - QRGdImageBMP::class => 'BMP Support', |
88 |
| - QRGdImageGIF::class => 'GIF Create Support', |
89 |
| - QRGdImageJPEG::class => 'JPEG Support', |
90 |
| - QRGdImagePNG::class => 'PNG Support', |
91 |
| - QRGdImageWEBP::class => 'WebP Support', |
| 87 | + QRGdImageAVIF::class => IMG_AVIF, |
| 88 | + QRGdImageBMP::class => IMG_BMP, |
| 89 | + QRGdImageGIF::class => IMG_GIF, |
| 90 | + QRGdImageJPEG::class => IMG_JPG, |
| 91 | + QRGdImagePNG::class => IMG_PNG, |
| 92 | + QRGdImageWEBP::class => IMG_WEBP, |
92 | 93 | ];
|
93 | 94 |
|
94 | 95 | // likely using custom output/manual invocation
|
95 | 96 | if(!isset($modes[$this->options->outputInterface])){
|
96 | 97 | return;
|
97 | 98 | }
|
98 | 99 |
|
99 |
| - $info = gd_info(); |
100 | 100 | $mode = $modes[$this->options->outputInterface];
|
101 | 101 |
|
102 |
| - if(!isset($info[$mode]) || $info[$mode] !== true){ |
| 102 | + if((imagetypes() & $mode) !== $mode){ |
103 | 103 | throw new QRCodeOutputException(sprintf('output mode "%s" not supported', $this->options->outputInterface));
|
104 | 104 | }
|
105 | 105 |
|
|
0 commit comments