diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index a4bb86781..75b1909d2 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -596,20 +596,11 @@ final class QRMatrix{ $height++; } - $dataModules = 0; - - // count the data modules - foreach($this->matrix as $y => $row){ - foreach($row as $x => $val){ - if($val === $this::M_DATA || $val >> 8 === $this::M_DATA){ - $dataModules++; - } - } - } + // $this->moduleCount includes the quiet zone (if created), we need the QR size here + $length = $this->version * 4 + 17; // throw if the logo space exceeds the maximum error correction capacity - // @todo: this might need some adjustment - if($width * $height > floor($dataModules * 0.3)){ + if($width * $height > floor($length * $length * 0.2)){ throw new QRCodeDataException('logo space exceeds the maximum error correction capacity'); }