mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-08 12:55:59 +00:00
:octocat: add logo space creation
This commit is contained in:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user