15317bbafSopenharmony_ciQR Code generator library - Python
25317bbafSopenharmony_ci==================================
35317bbafSopenharmony_ci
45317bbafSopenharmony_ci
55317bbafSopenharmony_ciIntroduction
65317bbafSopenharmony_ci------------
75317bbafSopenharmony_ci
85317bbafSopenharmony_ciThis project aims to be the best, clearest QR Code generator library. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments.
95317bbafSopenharmony_ci
105317bbafSopenharmony_ciHome page with live JavaScript demo, extensive descriptions, and competitor comparisons: https://www.nayuki.io/page/qr-code-generator-library
115317bbafSopenharmony_ci
125317bbafSopenharmony_ci
135317bbafSopenharmony_ciFeatures
145317bbafSopenharmony_ci--------
155317bbafSopenharmony_ci
165317bbafSopenharmony_ciCore features:
175317bbafSopenharmony_ci
185317bbafSopenharmony_ci* Significantly shorter code but more documentation comments compared to competing libraries
195317bbafSopenharmony_ci* Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
205317bbafSopenharmony_ci* Output format: Raw modules/pixels of the QR symbol
215317bbafSopenharmony_ci* Detects finder-like penalty patterns more accurately than other implementations
225317bbafSopenharmony_ci* Encodes numeric and special-alphanumeric text in less space than general text
235317bbafSopenharmony_ci* Open-source code under the permissive MIT License
245317bbafSopenharmony_ci
255317bbafSopenharmony_ciManual parameters:
265317bbafSopenharmony_ci
275317bbafSopenharmony_ci* User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data
285317bbafSopenharmony_ci* User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one
295317bbafSopenharmony_ci* User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number
305317bbafSopenharmony_ci* User can create a list of data segments manually and add ECI segments
315317bbafSopenharmony_ci
325317bbafSopenharmony_ciMore information about QR Code technology and this library's design can be found on the project home page.
335317bbafSopenharmony_ci
345317bbafSopenharmony_ci
355317bbafSopenharmony_ciExamples
365317bbafSopenharmony_ci--------
375317bbafSopenharmony_ci
385317bbafSopenharmony_ci```python
395317bbafSopenharmony_cifrom qrcodegen import *
405317bbafSopenharmony_ci
415317bbafSopenharmony_ci# Simple operation
425317bbafSopenharmony_ciqr0 = QrCode.encode_text("Hello, world!", QrCode.Ecc.MEDIUM)
435317bbafSopenharmony_cisvg = to_svg_str(qr0, 4)  # See qrcodegen-demo
445317bbafSopenharmony_ci
455317bbafSopenharmony_ci# Manual operation
465317bbafSopenharmony_cisegs = QrSegment.make_segments("3141592653589793238462643383")
475317bbafSopenharmony_ciqr1 = QrCode.encode_segments(segs, QrCode.Ecc.HIGH, 5, 5, 2, False)
485317bbafSopenharmony_cifor y in range(qr1.get_size()):
495317bbafSopenharmony_ci    for x in range(qr1.get_size()):
505317bbafSopenharmony_ci        (... paint qr1.get_module(x, y) ...)
515317bbafSopenharmony_ci```
525317bbafSopenharmony_ci
535317bbafSopenharmony_ciMore complete set of examples: https://github.com/nayuki/QR-Code-generator/blob/master/python/qrcodegen-demo.py .
54