:octocat: add logo space creation

This commit is contained in:
codemasher
2021-12-09 01:10:37 +01:00
parent 1aee1e90ca
commit 87f7f3aa4a
5 changed files with 127 additions and 29 deletions
-9
View File
@@ -16,9 +16,6 @@ use chillerlan\QRCode\Output\{QRCodeOutputException, QRImage};
use function imagecopyresampled, imagecreatefrompng, imagesx, imagesy, is_file, is_readable;
/**
* @property \chillerlan\QRCodeExamples\LogoOptions $options
*/
class QRImageWithLogo extends QRImage{
/**
@@ -38,12 +35,6 @@ class QRImageWithLogo extends QRImage{
throw new QRCodeOutputException('invalid logo');
}
$this->matrix->setLogoSpace(
$this->options->logoSpaceWidth,
$this->options->logoSpaceHeight
// not utilizing the position here
);
// there's no need to save the result of dump() into $this->image here
parent::dump($file);
+10 -20
View File
@@ -14,27 +14,17 @@ use chillerlan\QRCode\Common\EccLevel;
require_once __DIR__.'/../vendor/autoload.php';
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
/**
* @property int $logoSpaceWidth
* @property int $logoSpaceHeight
*
* @noinspection PhpIllegalPsrClassPathInspection
*/
class LogoOptions extends QROptions{
// size in QR modules, multiply with QROptions::$scale for pixel size
protected int $logoSpaceWidth;
protected int $logoSpaceHeight;
}
$options = new LogoOptions;
$options->version = 7;
$options->eccLevel = EccLevel::H;
$options->imageBase64 = false;
$options->logoSpaceWidth = 13;
$options->logoSpaceWidth = 13;
$options->scale = 5;
$options->imageTransparent = false;
$options = new QROptions([
'version' => 7,
'eccLevel' => EccLevel::H,
'imageBase64' => false,
'addLogoSpace' => true,
'logoSpaceWidth' => 13,
'logoSpaceHeight' => 13,
'scale' => 5,
'imageTransparent' => false,
]);
$qrcode = new QRCode($options);
$qrcode->addByteSegment($data);