Replies: 8 comments
-
Or change logo size. |
Beta Was this translation helpful? Give feedback.
-
Hi, can you please give me an example where version auto detection would break the qr generation? |
Beta Was this translation helpful? Give feedback.
-
4.3.x I have exception in file QRMatrix.php
Example
If, for example, logo size 13x13 and data is tiny string (Let be string so small that calculated version for her equal to module 3, it 21x21). Then it turns out that the logo overlaps more space than the eccLevel correction can compensate, and throws exceptions. |
Beta Was this translation helpful? Give feedback.
-
Best solution it calculate new lower logo size. With keeping it in the <30% size. In this case, the proportions of the logo remain more beautiful and save CPU time for calculate new largest module version. But incrementin module version is good solution too. |
Beta Was this translation helpful? Give feedback.
-
Ahh, now I see what you mean. I haven't thought about this yet because a) the logo space is not part of the specification (it is deliberately using the error correction capacity) and b) I'm assuming that if a logo space is set, a fixed qr code version is used. Resizing the logo space doesn't make much sense as the logo may not fit afterwards - especially when decreasing the logo space. Instead, throwing an exception when version auto detection is used would make more sense. |
Beta Was this translation helpful? Give feedback.
-
Increasing the module version does work, but I think it would be better if we manipulated, in this case, not the module version, but rather the size of the logo, and in general, abandon static logo sizes or introduce a new option like logoScale. Not everyone will be able to calculate everything correctly so that static logo sizes look good on all module versions between 1 and 15. On version 15, the logo will resemble a Earthworm Jim (there used to be such a cartoon and game, maybe you remember). It would be much better to introduce a logoScale instead of both logo sizes or like additional. For example, a maximum logoScale=100% is equivalent to 30% of the QR code size, and logoScale=50% is equivalent to 15% of the QR code size. And logoSpaceHeight and logoSpaceWidth calculate based on the proportions provided in logo-icon.png and logoScale param. Of course, I understand, that this is much more complicated than increasing modularity, and it may will break backward compatibility. Just keep this in mind when you start working on version 6. |
Beta Was this translation helpful? Give feedback.
-
I think it's too complex for too little practical use (the logo space method alone already adds too much complexity for my taste). Most of the implementations that I've seen are using a fixed qr version so that the output stays the same size. If you insist on scaling the logo space, you can still modify the matrix instance inside an extended output class: v4.3.x class MatrixModify extends QRImagick{
public function dump(string $file = null){
// exit early if the version is fixed
if($this->options->version !== QRCode::VERSION_AUTO){
return parent::dump($file);
}
// the version number
$versionNumber = $this->matrix->version();
// calculated size
$dimension = (($versionNumber * 4) + 17);
// ... calculate your desired logo space size...
$width = floor($dimension * 0.2);
$height = floor($dimension * 0.25);
$this->matrix->setLogoSpace($width, $height);
return parent::dump($file);
}
} Or for the v5.x beta: class MatrixModify extends QRImagick{
public function dump(string $file = null){
// exit early if the version is fixed
if($this->options->version !== Version::AUTO){
return parent::dump($file);
}
// get the version instance of the rendered matrix
$version = $this->matrix->getVersion();
// the version number
$versionNumber = $version->getVersionNumber();
// alternatively get the dimension (calculated size)
$dimension = $version->getDimension();
// ... calculate your desired logo space size...
$width = floor($dimension * 0.2);
$height = floor($dimension * 0.25);
$this->matrix->setLogoSpace($width, $height);
return parent::dump($file);
}
} |
Beta Was this translation helpful? Give feedback.
-
(I'm moving this to discussions) |
Beta Was this translation helpful? Give feedback.
-
Hi, I use version=VERSION_AUTO and logo for qr generation. My qr includes urls.
VERSION_AUTO is cool and fast, not need generate large qr for tiny urls.
But sometimes logo can break qr generation if it overlaps more space than the eccLevel correction can compensate that.
How about calculate version for this situation? Because value VERSION_AUTO hints at this.
Beta Was this translation helpful? Give feedback.
All reactions