[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: QRImagick.php
<?php /** * Class QRImagick * * @filesource QRImagick.php * @created 04.07.2018 * @package chillerlan\QRCode\Output * @author smiley <smiley@chillerlan.net> * @copyright 2018 smiley * @license MIT * * @noinspection PhpComposerExtensionStubsInspection */ namespace chillerlan\QRCode\Output; use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\QRCodeException; use chillerlan\Settings\SettingsContainerInterface; use Imagick, ImagickDraw, ImagickPixel; use function extension_loaded, is_string; /** * ImageMagick output module (requires ext-imagick) * * @see http://php.net/manual/book.imagick.php * @see http://phpimagick.com */ class QRImagick extends QROutputAbstract{ protected Imagick $imagick; /** * @inheritDoc */ public function __construct(SettingsContainerInterface $options, QRMatrix $matrix){ if(!extension_loaded('imagick')){ throw new QRCodeException('ext-imagick not loaded'); // @codeCoverageIgnore } parent::__construct($options, $matrix); } /** * @inheritDoc */ protected function setModuleValues():void{ foreach($this::DEFAULT_MODULE_VALUES as $type => $defaultValue){ $v = $this->options->moduleValues[$type] ?? null; if(!is_string($v)){ $this->moduleValues[$type] = $defaultValue ? new ImagickPixel($this->options->markupDark) : new ImagickPixel($this->options->markupLight); } else{ $this->moduleValues[$type] = new ImagickPixel($v); } } } /** * @inheritDoc * * @return string|\Imagick */ public function dump(string $file = null){ $file ??= $this->options->cachefile; $this->imagick = new Imagick; $this->imagick->newImage( $this->length, $this->length, new ImagickPixel($this->options->imagickBG ?? 'transparent'), $this->options->imagickFormat ); $this->drawImage(); if($this->options->returnResource){ return $this->imagick; } $imageData = $this->imagick->getImageBlob(); if($file !== null){ $this->saveToFile($imageData, $file); } return $imageData; } /** * Creates the QR image via ImagickDraw */ protected function drawImage():void{ $draw = new ImagickDraw; foreach($this->matrix->matrix() as $y => $row){ foreach($row as $x => $M_TYPE){ $draw->setStrokeColor($this->moduleValues[$M_TYPE]); $draw->setFillColor($this->moduleValues[$M_TYPE]); $draw->rectangle( $x * $this->scale, $y * $this->scale, ($x + 1) * $this->scale, ($y + 1) * $this->scale ); } } $this->imagick->drawImage($draw); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.8 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002