🔧 estimated bit length was correct, add a safety margin instead

This commit is contained in:
smiley
2024-02-27 15:39:22 +01:00
parent ccc73766e9
commit df49b3ffa4
3 changed files with 14 additions and 6 deletions
+4 -4
View File
@@ -164,9 +164,9 @@ final class QRData{
// it seems that in some cases the estimated total length is not 100% accurate,
// so we substract 4 bits from the total when not in mixed mode
# if(count($this->dataSegments) <= 1){
# $length -= 4;
# }
if(count($this->dataSegments) <= 1){
$length -= 4;
}
// we've got a match!
// or let's see if there's a higher version number available
@@ -194,7 +194,7 @@ final class QRData{
// guess the version number within the given range
for($version = $this->options->versionMin; $version <= $this->options->versionMax; $version++){
if($total <= $this->maxBitsForEcc[$version]){
if($total <= ($this->maxBitsForEcc[$version] - 4)){
return new Version($version);
}
}