WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
573 stars 123 forks source link

nos expected result with gs1_128 #75

Open ctc87 opened 4 years ago

ctc87 commented 4 years ago

When create barcode from string :

`
def generate_barcode(self):

    code = u"(01)01234567890128(15)057072"
    GS1 = barcode.get_barcode_class('gs1_128')
    fp = io.BytesIO()
    gs1 = GS1(code, writer=ImageWriter()).write(fp)
    a = base64.b64encode(fp.getbuffer())

` The expected result its: image The result obtanides its: image

WhyNotHugo commented 4 years ago

I tried a couple of barcode readers (including this one online), and the former barcode doesn't match the input string, but the generated one reads properly.

Can you clarify a bit more what's wrong?

diggy128 commented 3 years ago

@WhyNotHugo According to GS1 specs for GS-128, the parentheses enclosing the Application Identifiers (AIs) should be visible in the Human Readable Interpretation (HRI) (the string below the barcode) but should NOT be encoded in the barcode itself.

WhyNotHugo commented 3 years ago

Oh, I'd no idea. Do you have a link to this spec?

I guess the right fix then would be for this lib to add the parenthesis to the generated label, but not to the barcode itself.

diggy128 commented 3 years ago

GS1 General Specifications For GS1-128 see Pages 272-286

Regarding the parentheses in HRI see page 229: chapter 4.15, rule 3

Keep the specs at hand. It's a great source of information and the fact that it is freely available makes it invaluable.

I'll be around if you need anything else and I can help!

ctc87 commented 3 years ago

Finally y use external string with the barcode to generate the final image. The problem was the parentesis . Thx for aswer.

diggy128 commented 3 years ago

Please reopen. This does not work as it should.

ctc87 commented 3 years ago

Srry.

WhyNotHugo commented 3 years ago

I believe #100 (which has just been merged) should have fixed this.

Can you confirm this works fine?

diggy128 commented 3 years ago

Unfortunately it doesn't. I skimmed through the code and the PR has to do with EAN13 not GS128 (aka code128) and adding guard bars.

Parentheses are still encoded in the barcode. Am I missing something?

WhyNotHugo commented 3 years ago

My bad, mixed up barcodes 😅

diggy128 commented 3 years ago

Any news on this one?

jmarxuach commented 3 years ago

Hi, if you do :

gs1 = barcode.get_barcode_class('gs1_128')
barcode_img = gs1('90502087191121904229589045190400011980', writer=ImageWriter())

if you compare the image generated with the right image below, you can see they are diferent.

image

You read codebar generated, but in some cases it doesn't work.