treepoem

3.28.0 · active · verified Sat Apr 11

treepoem is a Python library (current version 3.28.0) for rendering various barcode types including QR code, Aztec, PDF417, I25, Code128, and Code39. It acts as a wrapper around the open-source BWIPP PostScript barcode library and utilizes the Ghostscript command-line tool for rendering. The library is actively maintained and typically sees frequent updates to its vendored BWIPP component.

Warnings

Install

Imports

Quickstart

This quickstart generates a QR code from a URL, adds a 10-pixel white border, and saves it as a monochrome PNG file named 'barcode.png'. The `ImageOps.expand` and `image.convert("1")` steps are common for preparing the output image.

import treepoem
from PIL import ImageOps

# Generate a QR code barcode
image = treepoem.generate_barcode(
    barcode_type="qrcode",
    data="https://www.example.com"
)

# Add a white border and save as a monochrome PNG
image = ImageOps.expand(image, border=10, fill="white")
image.convert("1").save("barcode.png")
print("Generated barcode.png")

view raw JSON →