Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages