python-barcode icon indicating copy to clipboard operation
python-barcode copied to clipboard

Wrong SVG generation for EAN13

Open ildarworld opened this issue 1 year ago • 1 comments

Don't know, is that a border case, but package generates wrong image for '5032783267860' in EAN13. its generate barcode for '5032783267863'. Generated file attached:

5032783267860

To reproduce the issue it just use following.

  • macOS Sonoma 14.5
  • chip Apple M1
  • python-barcode 0.15.1
  • python version 3.11.9
import barcode
from barcode.writer import SVGWriter

barcoder = barcode.get_barcode_class('EAN13')
writer = SVGWriter()
barcode_image = barcoder('5032783267860', writer=writer)
barcode_image.save('~/5032783267860.svg')

ildarworld avatar Jun 22 '24 13:06 ildarworld

The last digit is the verification digit, and this library will calculate it for you. If you want to force the provided digit, you need to use no_checksum=True.

WhyNotHugo avatar Aug 25 '24 16:08 WhyNotHugo