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
str
vs.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_fancy
for UTF-8 output (inspired byqrencode -t ansiutf8
) - bugfix for
DIGIT
→PUNCT
transition (and add missed test case) - allow customization of error correction percentage level
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:
size
andcompact
: to set a specific symbol size (e.g.19, True
for a compact 19×19 symbol); seekeys(aztec_code_generator.configs)
for possible valuesec_percent
for error correction percentage (default is the recommended 23), plussize
a
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.