This is a pure-Python library to generate Aztec Code 2D barcodes.
v0.1-v0.2: initial Python packagingv0.3: allow optional border, more efficient matrix representationv0.4: merge delimitry#5 and fix testsv0.5:- code simplification
- more efficient internal data structures (
Enum) - encoding of
FLG(n) - correct handling of Python 3
strvs.bytes(Aztec Code natively encodes bytes, not characters, and a reader's default interpretation of those bytes should be ISO-8859-1 aka Latin-1)
v0.6:- more code simplification
- make Pillow dependency optional
- add
print_fancyfor UTF-8 output (inspired byqrencode -t ansiutf8) - bugfix for
DIGIT→PUNCTtransition (and add missed test case) - allow customization of error correction percentage level
v0.7:- support standard-compliant encoding of strings in character sets other than ISO-8859-1 via ECI indications
v0.8-v0.9:- replace Travis-CI with Github Actions for CI
v0.10- bugfix for lowercase → uppercase transition (fixes encoding of strings like
abcABC)
- bugfix for lowercase → uppercase transition (fixes encoding of strings like
v0.11- fix docstrings
- change default
module_sizein image output to 2 pixels; ZXing can't read withmodule_size=1
Releases from PyPi may be installed with pip3 install aztec_code_generator.
Bleeding-edge version from master branch of this repository can be installed with
pip3 install https://github.com/dlenski/aztec_code_generator/archive/master.zip.
Pillow (Python image generation library) is required if you want to generate image objects and files.
from aztec_code_generator import AztecCode
data = 'Aztec Code 2D :)'
aztec_code = AztecCode(data)The AztecCode() constructor takes additional, optional arguments:
sizeandcompact: to set a specific symbol size (e.g.19, Truefor a compact 19×19 symbol); seekeys(aztec_code_generator.configs)for possible valuesec_percentfor error correction percentage (default is the recommended 23), plussizea
aztec_code.save('aztec_code.png', module_size=4, border=1) will save an image file aztec_code.png of the symbol, with 4×4 blocks of white/black pixels in
the output, and with a 1-block border.
aztec_code.image() will yield a monochrome-mode PIL Image object representing the image
in-memory. It also accepts optional module_size and border.
aztec_code.print_fancy() will print the resulting Aztec Code to standard output using
Unicode half-height block elements encoded
with UTF-8 and ANSI color escapes. It accepts optional border.
aztec_code.print_out() will print out the resulting Aztec Code to standard
output as plain ASCII text, using # and characters:
## # ## ####
# ## ##### ###
# ## # # # ###
## # # ## ##
## # # # #
## ############ # #
### # ### #
## # ##### # ## #
# # # # ##
# # # # # # ###
## # # ## ##
#### # ##### ## #
# ## ## ##
## ########### #
## # ## ## #
## # ### # ##
############
## # # ## #
## # ## ### #
Originally written by Dmitry Alimov (delimtry).
Updates, bug fixes, Python 3-ification, and careful bytes-vs.-str handling
by Daniel Lenski (dlenski).
Released under The MIT License.
