Aztec Code generator
This is a pure-Python library to generate Aztec Code 2D barcodes.
Changelog
v0.1-v0.2: initial Python packagingv0.3: allow optional border, more efficient matrix representationv0.4: merge https://github.com/delimitry/aztec_code_generator/pull/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
v0.12
Installation
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.
Dependencies
Pillow (Python image generation library) is required if you want to generate image objects and files.
Usage
Creating and encoding
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
Saving an image file
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.
Other image formats supported by Pillow are supported as well, as is SVG via a customized SVG generator. Although SVG files are losslessly scalable, they are generally an inefficient format for representing 2D barcodes, producing files ~3-5× larger than equivalent PNG images.
Example
Creating an image object
aztec_code.image() will yield a monochrome-mode PIL Image object representing the image
in-memory. It also accepts optional module_size and border.
Text-based output
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:
## # ## ####
# ## ##### ###
# ## # # # ###
## # # ## ##
## # # # #
## ############ # #
### # ### #
## # ##### # ## #
# # # # ##
# # # # # # ###
## # # ## ##
#### # ##### ## #
# ## ## ##
## ########### #
## # ## ## #
## # ### # ##
############
## # # ## #
## # ## ### #
Authors:
Originally written by Dmitry Alimov (delimtry).
Updates, bug fixes, Python 3-ification, packaging, and careful bytes-vs.-str handling
by Daniel Lenski (dlenski).
License:
Released under The MIT License.
Metadata
Release files for aztec_code_generator 0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aztec_code_generator-0.12.tar.gz | 12.2 kB | Without provenance | Details for aztec_code_generator-0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aztec_code_generator-0.12-py3-none-any.whl | Python 3 | none | any | Details for aztec_code_generator-0.12-py3-none-any.whl |
Total release size: 24.9 kB
Release files / aztec_code_generator-0.12.tar.gz
| Download URL | aztec_code_generator-0.12.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e27db502c081d0336406bb587ddfe837a8b0a5d44835522f1f21f470c964706b
|
|
BLAKE2b-256 checksum How to use checksums |
9ea06ec8038e82fe3cb845cdc8d274fcaecc8db6f911d31d6be9b357f3308d23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aztec_code_generator-0.12-py3-none-any.whl
| Download URL | aztec_code_generator-0.12-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8b498b5b93378e9c99226a7fada8811e41be33aa20973398d5eeebd19629909
|
|
BLAKE2b-256 checksum How to use checksums |
0a869c03721a209ca7b8e9c86ced0d4ade54d99faafb25098b520e9fc7694bcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for aztec_code_generator 0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.