Barcode rendering for Python 2 and 3 supporting QRcode, Aztec, PDF417, I25, Code128, Code39 and many more types.
Project description
A cleverly named, but very simple python barcode renderer wrapping the BWIPP library and ghostscript command line tool, Python 2.7 and 3.3+ compatible.
Installation
Install from pip:
pip install treepoem
You’ll also need Ghostscript installed. On Ubuntu/Debian this can be installed with:
apt-get install ghostscript
On Mac OS X use:
brew install ghostscript
Otherwise refer to your distribution’s package manager, though it’s likely to be called ghostscript too.
API
generate_barcode(barcode_type, data, options)
Generates a barcode and returns it as a PIL image file object (specifically, a PIL.EpsImagePlugin.EpsImageFile).
barcode_type is the name of the barcode type to generate (see below).
data is the string of data to embed in the barcode - the amount that can be embedded varies by type.
options is a dictionary of strings-to-strings of extra options to be passed to BWIPP, as per its docs.
For example, this generates a QR code image, and saves it to a file using standard PIL Image.save():
>>> import treepoem
>>> image = treepoem.generate_barcode(
... barcode_type='qrcode', # One of the BWIPP supported codes.
... data='barcode payload',
... options={},
... )
>>> image.save('barcode.png')
barcode_types
This is a set of the ~100 names of the barcode types that the vendored version of BWIPP supports. If you’re looking for whether a specific type is supported, check here.
The library is tested with these specific, common types:
qrcode - QR Code
azteccode - Aztec Code
pdf417 - PDF417
interleaved2of5 - Interleaved 2 of 5
code128 - Code 128
code39 - Code 39
What’s so clever about the name?
Barcode.
Bark ode.
Tree poem.
History
1.3.0 (2017-06-21)
Upgrade BWIPP from 2015-11-24 to 2017-06-20. This has a number of bug fixes, and supports more barcode types. It has also changed the pixel-for-pixel output of some formats, although they still encode the same information - notably QR codes, which are tested in treepoem's test suite. You can read its changelog in the vendored copy in the treepoem repo.
1.2.0 (2017-06-21)
Add treepoem.barcode_types, a set of all the names of supported barcode types, and error if asked to generate a barcode of an unknown type.
1.1.0 (2017-04-13)
Support Windows.
1.0.1 (2016-03-30)
Add the missing BWIPP files.
1.0.0 (2016-03-23)
Use $PATH to find gs binary.
Rename PostscriptError to TreepoemError.
Add basic setup.py.
Setup Travis CI build.
Setup Tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for treepoem-1.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d63581f82a75eb90858098abc2366ecdc271f809370a4b0593faffd6d4b8202f |
|
MD5 | 5695b4c1f89b4c9b1879d0c25e956e6b |
|
BLAKE2b-256 | 8050d6931d022fd9583f4d63868221e4e94915509f0df8f6b4c96f16f62a41a3 |