endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.45k stars 726 forks source link

Default margin if use ErrorCorrectionLevelLow #377

Closed kib-ev closed 2 years ago

kib-ev commented 2 years ago

When use errorCorrectionLevel = ErrorCorrectionLevelLow result png has default margin = about 10 even if set margin = 0 When use errorCorrectionLevel = ErrorCorrectionLevelHigh result png has default margin = 0 if set margin = 0

$result = Builder::create() ->writer(new PngWriter()) ->writerOptions([]) ->data($user->getAdGuid()) ->encoding(new Encoding('UTF-8')) ->errorCorrectionLevel(new ErrorCorrectionLevelLow()) ->size(300) ->margin(0) ->roundBlockSizeMode(new RoundBlockSizeModeMargin()) ->labelText(now()->format('d.m.Y H:i')) ->labelFont(new NotoSans(16)) ->labelAlignment(new LabelAlignmentCenter()) ->build();

endroid commented 2 years ago

Hi @kib-ev maybe this is related to the roundBlockSizeMode: the one you selected (margin) instructs the renderer to round block sizes to whole numbers (for sharpness) and use a margin if the number of blocks * block size is smaller than the desired image size. You can try using the RoundBlockSizeNone() mode, maybe this solves your issue.

Good luck!