diff --git a/disco.py b/disco.py index 8f99f90..0ef0365 100644 --- a/disco.py +++ b/disco.py @@ -204,8 +204,9 @@ def generate_barcode(upc: str, dest_dir: Path) -> Path | None: digits = re.sub(r"\D", "", upc) if not digits: return None - # UPC-A needs exactly 11 digits (12th is check digit, auto-calculated) - digits = digits[-11:].zfill(11) + # UPC-A: pass first 11 digits, library auto-calculates the 12th (check digit) + # A full UPC is 12 digits where the 12th is already the check digit + digits = digits[:11].zfill(11) try: upc_cls = barcode.get_barcode_class("upca") bc = upc_cls(digits, writer=ImageWriter())