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.
- It looks like qr codes encoding a URL sometimes do not work unless you add a "/" at the end.
OpenAPI
I used this package to learn how to use the fastapi package. The API that I created is available at https://qrgeneratorapi-1-c9139268.deta.app.
-
Use it to generate QR codes by sending GET requests to the API.
-
For now the API can return the QR code data or the QR code image encoded in base64.
-
Example usage:
-
import requests from PIL import Image import base64 url = 'https://qrgeneratorapi-1-c9139268.deta.app/qrimg/test' #get json r = requests.get(url) jsonData = r.json() #Get the json answer from the API size = jsonData["img"]["size"] base64Data = jsonData["img"]["base64"] imgdecoded = Image.frombytes('L', (size, size), base64.b64decode(base64Data)) #Decode the image imgdecoded.show() #Show the image
-
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 .png file, do not add the file format
--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.
Metadata
Release files for barcodes-uc 0.9.0
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 |
|---|---|---|---|---|
| barcodes_uc-0.9.0.tar.gz | 28.7 kB | Without provenance | Details for barcodes_uc-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| barcodes_uc-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for barcodes_uc-0.9.0-py3-none-any.whl |
Total release size: 57.4 kB
Release files / barcodes_uc-0.9.0.tar.gz
| Download URL | barcodes_uc-0.9.0.tar.gz |
|---|---|
| Size | 28.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2591686b35f23a129b0d61f158b3817f16dd4829ef8c293fd08e6511eb2ba000
|
|
BLAKE2b-256 checksum How to use checksums |
ffe0211613c1bc01ce348971928c2211332133ebc952d85b53ccf7fcf3f57595
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
|
Release files / barcodes_uc-0.9.0-py3-none-any.whl
| Download URL | barcodes_uc-0.9.0-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d881d299c15e26072f06d591da5d1d5d6f534a21ec7ae79628a9a916ed289202
|
|
BLAKE2b-256 checksum How to use checksums |
214059ab856f6d5ed3de8b3cafc46b64a0e256fcd4e3759c66516823b0f28d2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
|
Security for barcodes-uc 0.9.0
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.