Skip to content

Commit 0c46d60

Browse files
author
Martin Brecht-Precht
committed
Removed two issues occurring on use of unconfigured QrCodeRenderer instances.
1 parent caf2dfd commit 0c46d60

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/QrRender/QrCodeRendererPng.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class QrCodeRendererPng implements Base\QrCodeRendererInterface
2929
/**
3030
* @var int
3131
*/
32-
private $approximateSize;
32+
private $approximateSize = 1000;
3333

3434
/**
3535
* @var int
@@ -140,8 +140,8 @@ public function render(QrCode $qrCode, $filename)
140140

141141
// Calculate params
142142
$blockSize = round($this->approximateSize / ($width + 2 * self::MARGIN));
143-
$this->width = ($width + 2 * self::MARGIN) * $blockSize;
144-
$this->height = ($height + 2 * self::MARGIN) * $blockSize;
143+
$this->width = (int)($width + 2 * self::MARGIN) * $blockSize;
144+
$this->height = (int)($height + 2 * self::MARGIN) * $blockSize;
145145

146146
// Define colors
147147
$black = new \ImagickPixel($this->foregroundColor->getHex());

src/QrRender/QrCodeRendererTiff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class QrCodeRendererTiff implements Base\QrCodeRendererInterface
2929
/**
3030
* @var int
3131
*/
32-
private $approximateSize;
32+
private $approximateSize = 1000;
3333

3434
/**
3535
* @var int
@@ -137,9 +137,9 @@ public function render(QrCode $qrCode, $filename)
137137
$height = $qrCode->getHeight();
138138

139139
// Calculate params
140-
$blockSize = ceil($this->approximateSize / ($width + 2 * self::MARGIN));
141-
$this->width = ($width + 2 * self::MARGIN) * $blockSize;
142-
$this->height = ($height + 2 * self::MARGIN) * $blockSize;
140+
$blockSize = round($this->approximateSize / ($width + 2 * self::MARGIN));
141+
$this->width = (int)($width + 2 * self::MARGIN) * $blockSize;
142+
$this->height = (int)($height + 2 * self::MARGIN) * $blockSize;
143143

144144
// Define colors
145145
$black = new \ImagickPixel($this->foregroundColor->getImagickNotation());

0 commit comments

Comments
 (0)