:octocat: separate QR reader options

This commit is contained in:
smiley
2024-04-19 10:03:47 +02:00
parent dfb4ca90ab
commit 046016e76e
3 changed files with 51 additions and 36 deletions
+49
View File
@@ -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
View File
@@ -16,5 +16,5 @@ use chillerlan\Settings\SettingsContainerAbstract;
* The QRCode settings container
*/
class QROptions extends SettingsContainerAbstract{
use QROptionsTrait;
use QROptionsTrait, QRCodeReaderOptionsTrait;
}
+1 -35
View File
@@ -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)
*/