Skip to main content

Pure-Python Aztec Code 2D barcode generator - production-grade fork

Project description

aztec-py

CI PyPI Coverage mypy

Pure-Python Aztec Code 2D barcode generator.

Forked from dlenski/aztec_code_generator with production fixes, package modernization, SVG/PDF output, CLI tooling, and active maintenance.

What Is Aztec Code?

Aztec Code is a compact 2D barcode format standardized in ISO/IEC 24778. It can encode text or binary payloads with configurable error correction, and it does not require a quiet zone.

Install

pip install aztec-py

Optional extras:

pip install "aztec-py[pdf]"      # PDF output
pip install "aztec-py[decode]"   # Decode utility via python-zxing + Java
pip install "aztec-py[svg]"      # lxml-backed SVG workflows (optional)

Use In Your Project

Recommended dependency pins for production:

requirements.txt

aztec-py>=0.11,<1.0

pyproject.toml (PEP 621)

[project]
dependencies = [
  "aztec-py>=0.11,<1.0",
]

Install directly from GitHub when you need an unreleased fix:

pip install "aztec-py @ git+https://github.com/greyllmmoder/python-aztec.git@<tag-or-commit>"

For production, pin to a tag or commit SHA, not main.

Quick Start

from aztec_py import AztecCode

code = AztecCode("Hello World")
code.save("hello.png", module_size=4)
print(code.svg())

Production Validation

Run compatibility fixtures and generate a markdown report:

python scripts/decoder_matrix.py --report compat_matrix_report.md

The script is skip-safe when decode runtime requirements (zxing + Java) are unavailable. Use strict mode when decode checks are mandatory in CI:

python scripts/decoder_matrix.py --strict-decode

Generate full conformance evidence (markdown + JSON + compatibility matrix):

python scripts/conformance_report.py \
  --report conformance_report.md \
  --json conformance_report.json \
  --matrix-report compat_matrix_report.md

Fixture source: tests/compat/fixtures.json Traceability matrix: docs/ISO_IEC_24778_TRACEABILITY.md Release checklist: PRODUCTION_CHECKLIST.md

CLI

aztec "Hello World" --format terminal
aztec "Hello World" --format svg > code.svg
aztec "Hello World" --format png --module-size 4 --output code.png
aztec --ec 33 --charset ISO-8859-1 "Héllo" --format svg --output code.svg

Supported flags:

  • --format/-f: svg, png, terminal (default: terminal)
  • --module-size/-m: module size in pixels (default: 1)
  • --ec: error correction percent (default: 23)
  • --charset: text charset/ECI hint (default: UTF-8)
  • --output/-o: output file path (required for png)

API Reference

AztecCode

  • AztecCode(data, ec_percent=23, encoding=None, charset=None, size=None, compact=None)
  • image(module_size=2, border=0)
  • svg(module_size=1, border=1) -> str
  • pdf(module_size=3, border=1) -> bytes
  • save(path, module_size=2, border=0, format=None)
  • print_out(border=0)
  • print_fancy(border=0)

AztecRune

  • AztecRune(value) where value is in 0..255
  • image(), svg(), save(...)

GS1 Payload Helper

  • GS1Element(ai, data, variable_length=False)
  • build_gs1_payload([...]) -> str
  • GROUP_SEPARATOR (\x1d)

Example:

from aztec_py import AztecCode, GS1Element, build_gs1_payload

payload = build_gs1_payload(
    [
        GS1Element("01", "03453120000011"),
        GS1Element("17", "120508"),
        GS1Element("10", "ABCD1234", variable_length=True),
        GS1Element("410", "9501101020917"),
    ]
)
AztecCode(payload).save("gs1.png", module_size=4)

Decode Utility

from aztec_py import AztecCode, decode

code = AztecCode("test data")
decoded = decode(code.image())

Requires pip install "aztec-py[decode]" and a Java runtime.

GS1 Recipes

from aztec_py import GS1Element, build_gs1_payload
  1. GTIN + Expiry (fixed-length only)
build_gs1_payload([
    GS1Element("01", "03453120000011"),
    GS1Element("17", "120508"),
])
  1. GTIN + Batch/Lot + Ship To (variable field adds separator)
build_gs1_payload([
    GS1Element("01", "03453120000011"),
    GS1Element("10", "ABCD1234", variable_length=True),
    GS1Element("410", "9501101020917"),
])
  1. GTIN + Serial
build_gs1_payload([
    GS1Element("01", "03453120000011"),
    GS1Element("21", "SERIAL0001", variable_length=True),
])
  1. GTIN + Weight (kg)
build_gs1_payload([
    GS1Element("01", "03453120000011"),
    GS1Element("3103", "000750"),
])
  1. GTIN + Expiry + Serial + Destination
build_gs1_payload([
    GS1Element("01", "03453120000011"),
    GS1Element("17", "120508"),
    GS1Element("21", "XYZ12345", variable_length=True),
    GS1Element("410", "9501101020917"),
])

Comparison

Library Pure Python encode SVG CLI Rune PDF Notes
aztec-py Yes Yes Yes Yes Yes Active fork with bugfixes
dlenski/aztec_code_generator Yes PR pending No No No Upstream fork
delimitry/aztec_code_generator Yes No No No No Original lineage
treepoem No (BWIPP/Ghostscript backend) Via backend No Backend-dependent Via backend Wrapper-based
Aspose Barcode No (proprietary) Yes N/A Yes Yes Commercial SDK

Lineage and Attribution

Contributing

  • Read contribution guidelines: CONTRIBUTING.md
  • Security reporting process: SECURITY.md
  • Production release checks: PRODUCTION_CHECKLIST.md
  • To sync standard labels (after gh auth login): ./scripts/sync_labels.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aztec_py-0.11.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aztec_py-0.11.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file aztec_py-0.11.0.tar.gz.

File metadata

  • Download URL: aztec_py-0.11.0.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aztec_py-0.11.0.tar.gz
Algorithm Hash digest
SHA256 43c535b157fd00a5345ae417a649faf710bb359b2f435e46d53c85501b5f8ba2
MD5 87cc46fc60698461a4255e6d1965a1e5
BLAKE2b-256 3b8287f6531832a5171a5ba6f1983087164d980187e69754e9d394f1111f7ec8

See more details on using hashes here.

Provenance

The following attestation bundles were made for aztec_py-0.11.0.tar.gz:

Publisher: publish.yml on greyllmmoder/python-aztec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aztec_py-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: aztec_py-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aztec_py-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13e9c3bb0618f4af117785bcdfd2b3911bdbab28dde6cbfdd2146b894963596d
MD5 68926ed6e1aabb0e2b859fd2491604f4
BLAKE2b-256 7fe1be96342d2ee4ff21d12a26ad5184686ff043c3cd0f51b48ac19f200659a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for aztec_py-0.11.0-py3-none-any.whl:

Publisher: publish.yml on greyllmmoder/python-aztec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page