Skip to main content

Aztec Code generator in Python

Project description

Aztec Code generator

PyPI License: MIT Build Status

This is a pure-Python library to generate Aztec Code 2D barcodes.

Changelog

  • v0.1-v0.2: initial Python packaging
  • v0.3: allow optional border, more efficient matrix representation
  • v0.4: merge https://github.com/delimitry/aztec_code_generator/pull/5 and fix tests
  • v0.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 by qrencode -t ansiutf8)
    • bugfix for DIGITPUNCT transition (and add missed test case)
    • allow customization of error correction percentage level
  • v0.7:
  • 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)
  • v0.11
    • fix docstrings
    • change default module_size in image output to 2 pixels; ZXing can't read with module_size=1

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:

  • size and compact: to set a specific symbol size (e.g. 19, True for a compact 19×19 symbol); see keys(aztec_code_generator.configs) for possible values
  • ec_percent for error correction percentage (default is the recommended 23), plus size a

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.

Aztec Code

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, and careful bytes-vs.-str handling by Daniel Lenski (dlenski).

License:

Released under The MIT License.

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_code_generator-0.11.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

aztec_code_generator-0.11.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file aztec_code_generator-0.11.1.tar.gz.

File metadata

  • Download URL: aztec_code_generator-0.11.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for aztec_code_generator-0.11.1.tar.gz
Algorithm Hash digest
SHA256 abb86e2bf6678561b9881a9c16b4c9fe92b4572698e68830b04035eeaf55b28a
MD5 d3cd850736d7fe53103bb6956ffd2069
BLAKE2b-256 ea719e2c6d77408dc8a7489da966ab720ed04500abff97cd3b0b0849e3eb3391

See more details on using hashes here.

File details

Details for the file aztec_code_generator-0.11.1-py3-none-any.whl.

File metadata

  • Download URL: aztec_code_generator-0.11.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for aztec_code_generator-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4baaeb802b0cc6d735be1c8ea1aadcd7ad82ea56753d1bcc28b0cb9bd585d266
MD5 36deb10c9cc9e251c43b4d0a48580c88
BLAKE2b-256 422f2525366bb1d6a49e9abe7a93fc2d66dc6f93ec3ea533dce5343a89310294

See more details on using hashes here.

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