mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-30 12:07:32 +00:00
🚿 remove ext-gd requirement, check extension_loaded instead
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.4",
|
||||
"ext-gd": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"chillerlan/php-settings-container": "^1.2"
|
||||
|
||||
+17
-2
@@ -9,15 +9,18 @@
|
||||
* @copyright 2015 Smiley
|
||||
* @license MIT
|
||||
*
|
||||
* @noinspection PhpComposerExtensionStubsInspection
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCode\Output;
|
||||
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\{QRCode, QRCodeException};
|
||||
use chillerlan\Settings\SettingsContainerInterface;
|
||||
use Exception;
|
||||
|
||||
use function array_values, base64_encode, call_user_func, count, imagecolorallocate, imagecolortransparent,
|
||||
use function array_values, base64_encode, call_user_func, count, extension_loaded, imagecolorallocate, imagecolortransparent,
|
||||
imagecreatetruecolor, imagedestroy, imagefilledrectangle, imagegif, imagejpeg, imagepng, in_array,
|
||||
is_array, ob_end_clean, ob_get_contents, ob_start, range, sprintf;
|
||||
|
||||
@@ -28,6 +31,18 @@ use function array_values, base64_encode, call_user_func, count, imagecoloralloc
|
||||
*/
|
||||
class QRImage extends QROutputAbstract{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function __construct(SettingsContainerInterface $options, QRMatrix $matrix){
|
||||
|
||||
if(!extension_loaded('gd')){
|
||||
throw new QRCodeException('ext-gd not loaded');
|
||||
}
|
||||
|
||||
parent::__construct($options, $matrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* GD image types that support transparency
|
||||
*
|
||||
|
||||
@@ -14,9 +14,12 @@
|
||||
|
||||
namespace chillerlan\QRCode\Output;
|
||||
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\QRCodeException;
|
||||
use chillerlan\Settings\SettingsContainerInterface;
|
||||
use Imagick, ImagickDraw, ImagickPixel;
|
||||
|
||||
use function is_string;
|
||||
use function extension_loaded, is_string;
|
||||
|
||||
/**
|
||||
* ImageMagick output module (requires ext-imagick)
|
||||
@@ -26,6 +29,18 @@ use function is_string;
|
||||
*/
|
||||
class QRImagick extends QROutputAbstract{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function __construct(SettingsContainerInterface $options, QRMatrix $matrix){
|
||||
|
||||
if(!extension_loaded('imagick')){
|
||||
throw new QRCodeException('ext-imagick not loaded');
|
||||
}
|
||||
|
||||
parent::__construct($options, $matrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user