From 8f990a2c625ad1f580be18148dbaed64e9015633 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Mon, 13 Jul 2020 22:15:58 +0200 Subject: [PATCH] Use new ROUND_BLOCK_SIZE_MODE_ENLARGE This will make pixel based qr codes (like png) sharper and smaller in file size. On the other hand, the exact final image size may vary. --- composer.json | 2 +- composer.lock | 16 +++++++++------- src/QrBill.php | 11 +++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 2312a340..4641fc8b 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "symfony/intl": "^3.4|^4.2|^5.0", "khanamiryan/qrcode-detector-decoder": "^1.0.3", "kmukku/php-iso11649": "^1.5", - "endroid/qr-code": "^3.8.2" + "endroid/qr-code": "^3.9" }, "require-dev": { "phpunit/phpunit": "^6.4|^7.0", diff --git a/composer.lock b/composer.lock index 57b67451..9d4349a4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "65e29d756b1541f4d9333de259d65ab5", + "content-hash": "1ddc7e7f913eef77d9e6936323c0f1fe", "packages": [ { "name": "bacon/bacon-qr-code", @@ -99,16 +99,16 @@ }, { "name": "endroid/qr-code", - "version": "3.8.2", + "version": "3.9.1", "source": { "type": "git", "url": "https://github.com/endroid/qr-code.git", - "reference": "1616778c697238b16e1b7592ea824bafcf7d108c" + "reference": "8605e2c958ed568788da4e16bd8a9502e32f375f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/endroid/qr-code/zipball/1616778c697238b16e1b7592ea824bafcf7d108c", - "reference": "1616778c697238b16e1b7592ea824bafcf7d108c", + "url": "https://api.github.com/repos/endroid/qr-code/zipball/8605e2c958ed568788da4e16bd8a9502e32f375f", + "reference": "8605e2c958ed568788da4e16bd8a9502e32f375f", "shasum": "" }, "require": { @@ -121,10 +121,12 @@ "symfony/property-access": "^3.4||^4.4||^5.0" }, "require-dev": { - "endroid/quality": "dev-master" + "endroid/quality": "dev-master", + "setasign/fpdf": "^1.8" }, "suggest": { "roave/security-advisories": "Avoids installation of package versions with vulnerabilities", + "setasign/fpdf": "Required to use the FPDF writer.", "symfony/security-checker": "Checks your composer.lock for vulnerabilities" }, "type": "library", @@ -158,7 +160,7 @@ "qr", "qrcode" ], - "time": "2020-06-19T08:57:37+00:00" + "time": "2020-07-10T10:16:06+00:00" }, { "name": "khanamiryan/qrcode-detector-decoder", diff --git a/src/QrBill.php b/src/QrBill.php index 65d3e0b9..9aff24f1 100644 --- a/src/QrBill.php +++ b/src/QrBill.php @@ -31,6 +31,9 @@ class QrBill implements SelfValidatableInterface private const SWISS_CROSS_LOGO_FILE = __DIR__ . '/../assets/swiss-cross.optimized.png'; + private const PX_QR_CODE = 543; // recommended 46x46 mm in px @ 300dpi – in pixel based outputs, the final image size may be slightly different, depending on the qr code contents + private const PX_SWISS_CROSS = 83; // recommended 7x7 mm in px @ 300dpi + /** @var Header */ private $header; @@ -195,11 +198,11 @@ public function getQrCode(): QrCode $qrCode = new QrCode(); $qrCode->setText($this->getQrCodeContent()); - $qrCode->setSize(543); // recommended 46x46 mm in px @ 300dpi - $qrCode->setLogoHeight(83); // recommended 7x7 mm in px @ 300dpi - $qrCode->setLogoWidth(83); // recommended 7x7 mm in px @ 300dpi + $qrCode->setSize(self::PX_QR_CODE); + $qrCode->setLogoHeight(self::PX_SWISS_CROSS); + $qrCode->setLogoWidth(self::PX_SWISS_CROSS); $qrCode->setLogoPath(self::SWISS_CROSS_LOGO_FILE); - $qrCode->setRoundBlockSize(false); + $qrCode->setRoundBlockSize(true, \Endroid\QrCode\QrCode::ROUND_BLOCK_SIZE_MODE_ENLARGE); $qrCode->setMargin(0); $qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel($this->errorCorrectionLevel));