QRCodeReaderOptionsTrait.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * QRCodeReaderOptionsTrait.php
  4. *
  5. * @created 01.03.2024
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2024 smiley
  8. * @license MIT
  9. */
  10. namespace chillerlan\QRCode;
  11. use function extension_loaded;
  12. /**
  13. * Trait QRCodeReaderOptionsTrait
  14. */
  15. trait QRCodeReaderOptionsTrait{
  16. /**
  17. * Use Imagick (if available) when reading QR Codes
  18. */
  19. protected bool $readerUseImagickIfAvailable = false;
  20. /**
  21. * Grayscale the image before reading
  22. */
  23. protected bool $readerGrayscale = false;
  24. /**
  25. * Invert the colors of the image
  26. */
  27. protected bool $readerInvertColors = false;
  28. /**
  29. * Increase the contrast before reading
  30. *
  31. * note that applying contrast works different in GD and Imagick, so mileage may vary
  32. */
  33. protected bool $readerIncreaseContrast = false;
  34. /**
  35. * enables Imagick for the QR Code reader if the extension is available
  36. */
  37. protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
  38. $this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
  39. }
  40. }