qr¶
Minimal QR code encoder (byte mode, versions 1-4, error levels L and M).
Enough for a URL like “http://192.168.188.81/” (versions 1-4 hold up to 62 bytes at level M). Follows ISO/IEC 18004 as explained in Project Nayuki’s reference implementation (https://www.nayuki.io/page/qr-code- generator-library, MIT).
Attributes¶
Functions¶
Module Contents¶
- qr.MAX_VERSION = 4¶
- qr.encode(text, ecl='M', mask=None)¶
Encode
textas a QR code.Picks the smallest version and, unless
maskis given, the mask with the lowest penalty.- Parameters:
text – Text to encode (byte mode).
ecl – Error correction level, “L” or “M”.
mask – Mask pattern 0-7, or None to choose the best.
- Returns:
A list of rows, each a bytearray of 0/1 (1 = dark), without quiet zone.
- Raises:
ValueError – If the text does not fit into a version 4 code.