mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-17 23:21:13 +00:00
:octocat: separate QR reader options
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* QRCodeReaderOptionsTrait.php
|
||||
*
|
||||
* @created 01.03.2024
|
||||
* @author smiley <smiley@chillerlan.net>
|
||||
* @copyright 2024 smiley
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCode;
|
||||
|
||||
use function extension_loaded;
|
||||
|
||||
/**
|
||||
* Trait QRCodeReaderOptionsTrait
|
||||
*/
|
||||
trait QRCodeReaderOptionsTrait{
|
||||
|
||||
/**
|
||||
* Use Imagick (if available) when reading QR Codes
|
||||
*/
|
||||
protected bool $readerUseImagickIfAvailable = false;
|
||||
|
||||
/**
|
||||
* Grayscale the image before reading
|
||||
*/
|
||||
protected bool $readerGrayscale = false;
|
||||
|
||||
/**
|
||||
* Invert the colors of the image
|
||||
*/
|
||||
protected bool $readerInvertColors = false;
|
||||
|
||||
/**
|
||||
* Increase the contrast before reading
|
||||
*
|
||||
* note that applying contrast works different in GD and Imagick, so mileage may vary
|
||||
*/
|
||||
protected bool $readerIncreaseContrast = false;
|
||||
|
||||
/**
|
||||
* enables Imagick for the QR Code reader if the extension is available
|
||||
*/
|
||||
protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
|
||||
$this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -16,5 +16,5 @@ use chillerlan\Settings\SettingsContainerAbstract;
|
||||
* The QRCode settings container
|
||||
*/
|
||||
class QROptions extends SettingsContainerAbstract{
|
||||
use QROptionsTrait;
|
||||
use QROptionsTrait, QRCodeReaderOptionsTrait;
|
||||
}
|
||||
|
||||
+1
-35
@@ -16,7 +16,7 @@ namespace chillerlan\QRCode;
|
||||
|
||||
use chillerlan\QRCode\Common\{EccLevel, MaskPattern, Version};
|
||||
use chillerlan\QRCode\Output\QRMarkupSVG;
|
||||
use function constant, extension_loaded, in_array, is_string, max, min, sprintf, strtolower, strtoupper, trim;
|
||||
use function constant, in_array, is_string, max, min, sprintf, strtolower, strtoupper, trim;
|
||||
use const JSON_THROW_ON_ERROR, PHP_EOL;
|
||||
|
||||
/**
|
||||
@@ -427,33 +427,6 @@ trait QROptionsTrait{
|
||||
protected string $fpdfMeasureUnit = 'pt';
|
||||
|
||||
|
||||
/*
|
||||
* QR Code reader settings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use Imagick (if available) when reading QR Codes
|
||||
*/
|
||||
protected bool $readerUseImagickIfAvailable = false;
|
||||
|
||||
/**
|
||||
* Grayscale the image before reading
|
||||
*/
|
||||
protected bool $readerGrayscale = false;
|
||||
|
||||
/**
|
||||
* Invert the colors of the image
|
||||
*/
|
||||
protected bool $readerInvertColors = false;
|
||||
|
||||
/**
|
||||
* Increase the contrast before reading
|
||||
*
|
||||
* note that applying contrast works different in GD and Imagick, so mileage may vary
|
||||
*/
|
||||
protected bool $readerIncreaseContrast = false;
|
||||
|
||||
|
||||
/**
|
||||
* clamp min/max version number
|
||||
*/
|
||||
@@ -534,13 +507,6 @@ trait QROptionsTrait{
|
||||
// @todo throw or ignore silently?
|
||||
}
|
||||
|
||||
/**
|
||||
* enables Imagick for the QR Code reader if the extension is available
|
||||
*/
|
||||
protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
|
||||
$this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
|
||||
}
|
||||
|
||||
/**
|
||||
* clamp the logo space values between 0 and maximum length (177 modules at version 40)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user