PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor_prefixed / chillerlan / php-qrcode / src / Common / IMagickLuminanceSource.php

IMagickLuminanceSource.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.20, at vendor_prefixed/chillerlan/php-qrcode/src/Common/IMagickLuminanceSource.php

71 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class IMagickLuminanceSource
5 *
6 * @created 17.01.2021
7 * @author Ashot Khanamiryan
8 * @author Smiley <[email protected]>
9 * @copyright 2021 Smiley
10 * @license MIT
11 *
12 * @noinspection PhpComposerExtensionStubsInspection
13 */
14 namespace WCPOS\Vendor\chillerlan\QRCode\Common;
15
16 use WCPOS\Vendor\chillerlan\Settings\SettingsContainerInterface;
17 use Imagick;
18 use function count;
19 /**
20 * This class is used to help decode images from files which arrive as Imagick Resource
21 * It does not support rotation.
22 */
23 class IMagickLuminanceSource extends LuminanceSourceAbstract
24 {
25 protected Imagick $imagick;
26 /**
27 * IMagickLuminanceSource constructor.
28 */
29 public function __construct(Imagick $imagick, ?SettingsContainerInterface $options = null)
30 {
31 parent::__construct($imagick->getImageWidth(), $imagick->getImageHeight(), $options);
32 $this->imagick = $imagick;
33 if ($this->options->readerGrayscale) {
34 $this->imagick->setImageColorspace(Imagick::COLORSPACE_GRAY);
35 }
36 if ($this->options->readerInvertColors) {
37 $this->imagick->negateImage($this->options->readerGrayscale);
38 }
39 if ($this->options->readerIncreaseContrast) {
40 for ($i = 0; $i < 10; $i++) {
41 $this->imagick->contrastImage(\false);
42 // misleading docs
43 }
44 }
45 $this->setLuminancePixels();
46 }
47 /**
48 *
49 */
50 protected function setLuminancePixels() : void
51 {
52 $pixels = $this->imagick->exportImagePixels(1, 1, $this->width, $this->height, 'RGB', Imagick::PIXEL_CHAR);
53 $count = count($pixels);
54 for ($i = 0; $i < $count; $i += 3) {
55 $this->setLuminancePixel($pixels[$i] & 0xff, $pixels[$i + 1] & 0xff, $pixels[$i + 2] & 0xff);
56 }
57 }
58 /** @inheritDoc */
59 public static function fromFile(string $path, ?SettingsContainerInterface $options = null) : self
60 {
61 return new self(new Imagick(self::checkFile($path)), $options);
62 }
63 /** @inheritDoc */
64 public static function fromBlob(string $blob, ?SettingsContainerInterface $options = null) : self
65 {
66 $im = new Imagick();
67 $im->readImageBlob($blob);
68 return new self($im, $options);
69 }
70 }
71