bnomei / kirby3-qrcode

Generate QRCodes easily.
https://forum.getkirby.com/t/plugin-qr-code-field-and-page-method/6798
MIT License
12 stars 3 forks source link

Size varies #19

Closed psntr closed 2 years ago

psntr commented 2 years ago

Hi,

Thank you for the plugin. I'm trying to always get the size inner size of the QR code for printing reason. But depending of course of the length of the text, sometimes the QR code inner size is a bit smaller or larger. Even when the margin option are set or the size option.

I don't know if there is way to ensure the same size? I tried to look for options in here, but not sure if it's related.

psntr commented 2 years ago

Ok, I dig a bit further more the files from endroid, played around with the settings, this seems to work:

$qrcodeObject = new \Bnomei\QRCode([
            'Text' => 'my long text',
            'size' => 320,
            'roundBlockSizeMode' => new Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeNone,
            'margin' => 0
        ]);
        echo $qrcodeObject->html('qrcode.svg');

But woud appreciate your insight.

bnomei commented 2 years ago

i do not have more information on this than you do.

if your last fix works you can set them as defaults via the config, right?

or do you think i should add them to the codebase as defaults?

psntr commented 2 years ago

Thank you for your reply. I don't think it needs to be by default on your codebase because it's also the default mode in Endroid and also the "optimal". At least from what I understood: margin (default): the size of the QR code is shrunk if necessary but the size of the final image remains unchanged due to additional margin being added. So the default mode RoundBlockSizeModeMargin, was what makes my inner QR code smaller because the margin was re-adjusted automatically even if you set a margin.

Maybe you could add in the Readme the equivalent of: ->roundBlockSizeMode(new RoundBlockSizeModeNone()) from endroid to your plugin is: 'roundBlockSizeMode' => new Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeNone

I'm not sure but these seems to be other options 'roundBlockSizeMode' => new Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeShrink 'roundBlockSizeMode' => new Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin // default 'roundBlockSizeMode' => new Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeEnlarge

Closing the issue since it's fixed. Again thanks for looking into that.