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)

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

Uploaded Source

Built Distribution

aztec_code_generator-0.11-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aztec_code_generator-0.11.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for aztec_code_generator-0.11.tar.gz
Algorithm Hash digest
SHA256 6634d54354974b31d94e8d4ac2682337ee15816803e4bea8d1b39ae8dd246b68
MD5 a2ed77dd83574bea18ce3a177ab91bf5
BLAKE2b-256 1f2fb9273de94780611c9a6cb9f4b5774455a2f35d9833ac37be2706b171ed9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aztec_code_generator-0.11-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for aztec_code_generator-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 8d2e2377e2113393a3710c92bfec30c8fe6bc61ffcba2c5241f18157ff441488
MD5 01f1d7457705fa65ab5a75cd1c0ccd80
BLAKE2b-256 6f9f3d091b25cb28f21e7086e4751a579543519dea23634bca8a8bbe9f2316b6

See more details on using hashes here.

Supported by

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