Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyBarcode code39 adds random digit

Tags:

python

I am creating a .png barcode from an alpha numerical value. I am using Python and the pyBarcode module. The problem is that, when I use code39, it adds a random digit to the end. Other barcode formats I tested seems to give the same problem.

Here is my code snippet

unique_filename = uuid.uuid4()
barcode_writer = ImageWriter()
ean = barcode.get('code39', "Testing-One-two-1-2",barcode_writer)
filename = ean.save(BARCODE_DIR +str(unique_filename))

And the created .png:

Non-OP Edit: Link to image is now broken.

Hope someone can assist me. Thanks

like image 310
Overklog Avatar asked Sep 03 '25 14:09

Overklog


1 Answers

Looking at the source code for pyBarcode init function on line 57 the barcode.get() function calls:

return barcode(code, writer)

So it creates a barcode with the parameters code and writer set.

In the codex.py file on line 52, the code39 class is created with the checksum parameter True by default:

def __init__(self, code, writer=None, add_checksum=True):

And as per lnmx you have to explicitly set the checksum off if you don't want it.

like image 196
Peter M Avatar answered Sep 05 '25 05:09

Peter M