lincolnloop / python-qrcode

Python QR Code image generator
https://pypi.python.org/pypi/qrcode
Other
4.34k stars 664 forks source link

Use different mask pattern in Format String #251

Closed dbarrerap closed 2 years ago

dbarrerap commented 2 years ago

According to this documentation, the format string consists of ECC Level and a Mask Pattern. Doing some tests, the implementation of ERROR_CORRECT_H uses Mask Pattern 2.

Is there a way to modify the Mask Pattern used in order to use a specific Format String?

heuer commented 2 years ago

The mask pattern depends on the data, see https://www.thonky.com/qr-code-tutorial/data-masking You shouldn't assume that a Qr code using error level H uses always mask pattern 2.

However, it is possible to specify the mask pattern:

qr_img = qrcode.make(data='Test', mask_pattern=3)

Please note that this may lead to a QR code which uses an unoptimized layout. As stated above the mask pattern depends on the data and masking ensures that the QR code is easily readable.

dbarrerap commented 2 years ago

Thanks for this information, I didn't read the part you sent. I'll close this issue.