Skip to content

Instantly share code, notes, and snippets.

@benhosmer
Created February 12, 2015 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhosmer/4d2c1875d8257b78c972 to your computer and use it in GitHub Desktop.
Save benhosmer/4d2c1875d8257b78c972 to your computer and use it in GitHub Desktop.
Python using elaphe to generate UPC A Barcodes
#/usr/bin/env python
# Install elaphe first
# pip install elaphe
from elaphe.upc import UpcA
upc_a = UpcA()
# Just a simple dictionary of numbers. If I remember right, I had to use UPC A because they had the number of characters I needed
# to correlate with the user id.
# You could easily read this from an exported file too.
codes = ['00000000001', '00000000002', '00000000003']
for x in codes:
upca_image = upc_a.render(x, options=dict(includetext=True), scale=3, margin=1)
upca_image.save(x + '.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment