Skip to main content

A library to generate barcodes

Project description

Barcodes python module

Thanks to Melisa for her precious help.

⚠️ This python package is still in development. ⚠️

  • For now only QR codes are available. Only alphanumeric and byte encodings are available.

Installation

pip install barcodes-uc

You might want to install the package in a virtual environment. For that do:

python3 -m venv venv
source venv/bin/activate
pip install barcodes-uc

Usage

from barcodes_uc.qrcodes import qrgenerator, qrutils

# Generate a QR code
message = "Hello world!"
encoding = qrutils.QREncoding.byte
version, error_correction_level, qr = qrgenerator.get_min_version(message, encoding, qrutils.QRErrorCorrectionLevels.Q)
generator = qrgenerator.QRGenerator(msg=message, encoding=encoding, version=version, error_correction=error_correction_level)
qr = generator.generate()

qr.show() # Show the QR code in the terminal
qr.save("qr.png", imgSize = 1000, colour=[qrgenerator.QRColour.red]) # Save the QR code in a file

CLI tools

The package comes with CLI tools:

QR code generator

qrcode --help
usage: qrcode [-h] [-e {byte,numeric,alphanumeric,kanji}] [-V QR_VERSION] [-E {L,M,Q,H}] [--save SAVE] [--no-show] message

Create QR codes

positional arguments:
  message               Message to encode

optional arguments:
  -h, --help            show this help message and exit
  -e {byte,numeric,alphanumeric,kanji}, --encoding {byte,numeric,alphanumeric,kanji}
                        Encoding of the message
  -V QR_VERSION, --qr-version QR_VERSION
                        QR version, 1-40
  -E {L,M,Q,H}, --qr-error-correction {L,M,Q,H}
                        QR error correction
  --save SAVE           Save the QR code to a file
  --no-show             Do not show the QR code
  
Made by Pedro Juan Royo, @UnstrayCato

The program will show the QR code in the terminal and save it to a file if the --save option is used. If no -e, -V or -E options are used, the program will try to guess the best options for the message.

Future work

  • Add byte and numeric encoding to qr codes.

  • Save qr code as image in different styles.

  • Generate barcodes.

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

barcodes_uc-0.7.0.tar.gz (80.5 kB view hashes)

Uploaded Source

Built Distribution

barcodes_uc-0.7.0-py3-none-any.whl (28.1 kB view hashes)

Uploaded Python 3

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