Skip to main content

larzbarcode

EAN-13 and Code 128 barcodes as SVG — zero dependencies.

Encode retail EAN-13 product codes and general-purpose Code 128 (ASCII) into a module bitmap and a crisp SVG, with correct check digits and the standard patterns. No image library. Pairs naturally with larzqr when you need 2D codes too.

Install

pip install larzbarcode

Use

from larzbarcode import ean13, code128, ean13_check_digit

ean13("400638133393").to_svg("product.svg")   # 12 digits -> check digit appended
ean13("4006381333931")                         # or pass 13 (verified)
code128("SHIP-42").to_svg("label.svg")

ean13_check_digit("978014300723")              # 4
ean13("4006381333931").modules                 # the 0/1 bar pattern (95 modules)

Why it's correct

  • EAN-13 check digits are verified against known real codes, and the output is the fixed 95-module structure with correct guard bars (101 … 01010 … 101).
  • Code 128 uses the standard 107-pattern table (validated internally — every pattern's bar/space widths sum to 11, the stop to 13) with the weighted mod-103 checksum.

Tests

python -m unittest discover -s tests -v   # 16 tests

The Larz stack

One of 60+ pure-Python, zero-dependency libraries at github.com/larz-scripter. The 1D companion to larzqr (QR codes).

License

MIT (c) larz-scripter

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larzbarcode-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzbarcode-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file larzbarcode-0.1.0.tar.gz.

File metadata

  • Download URL: larzbarcode-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzbarcode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b00d5ee32e947d419f216f7b7fc0f8155dbf6fbf174e66409b145d238c5f5785
MD5 f1cad9096c75d752ff21ec47e8b861ec
BLAKE2b-256 aa8b8d56ec2c44da87f35bf24ca5d373dd1151ad380236f84d92504843115f7e

See more details on using hashes here.

File details

Details for the file larzbarcode-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzbarcode-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzbarcode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51870b257aff58d0a0d207e4f3fe94cb52dc94d7515e21dfaaf3107a9b03da1e
MD5 4bc7bc51ec397fa5c8bd55e8ebc04f03
BLAKE2b-256 ec078ad71f9a6113eeccd868d46d0aaae489d334aa91532a9b1f48620c4452a7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page