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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b00d5ee32e947d419f216f7b7fc0f8155dbf6fbf174e66409b145d238c5f5785
|
|
| MD5 |
f1cad9096c75d752ff21ec47e8b861ec
|
|
| BLAKE2b-256 |
aa8b8d56ec2c44da87f35bf24ca5d373dd1151ad380236f84d92504843115f7e
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51870b257aff58d0a0d207e4f3fe94cb52dc94d7515e21dfaaf3107a9b03da1e
|
|
| MD5 |
4bc7bc51ec397fa5c8bd55e8ebc04f03
|
|
| BLAKE2b-256 |
ec078ad71f9a6113eeccd868d46d0aaae489d334aa91532a9b1f48620c4452a7
|