Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect barcode #7

Open
AndyM48 opened this issue Sep 23, 2021 · 9 comments
Open

Incorrect barcode #7

AndyM48 opened this issue Sep 23, 2021 · 9 comments

Comments

@AndyM48
Copy link
Contributor

AndyM48 commented Sep 23, 2021

The latest updates look very good. Thank you very much.
So I have added my Intermarche card, one of the cards with 19 digits. The output for the entry was:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Card Name: Intermarche barcodeEntry: 3250390100098299963
comeFromEditSave:0
We will do an INSERT instead of update because it is not an edit
No Back or front image entered
Accessed SearchTab:
searchParam:%%
67 Example Card
94 Intermarche
cardName:Intermarche
codebar:3250390100098299963
id0:94
codebarYey:3250390100098299963
Barcode correctly Saved
No image where given
No image where given
cardName:Example Card
codebar: 123456789101
id0:67
codebarYey:123456789101
Barcode correctly Saved
Stored blob data into: tmp/67.jpg

Stored blob data into: tmp/67_back.jpg

cardName:Intermarche
codebar:3250390100098299963
id0:94
codebarYey:3250390100098299963
Barcode correctly Saved
No image where given
No image where given
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Unfortunately, although the card number is saved and displayed as 3250390100098299963 the barcode is incorrect and displayed as 3250390100096

20210923_10h06m27s_grim

I know you are not keen on using the barcode programme to create the barcodes but compare the difference between the two:
$ barcode -b 3250390100098299963 -S -o storecard.svg
$ barcode -b 3250390100096 -S -o barcode.svg

PS: The Example card is not shown until Entry Cards is selected for the first time

Edit:
Actually no cards are shown until Entry Cards is selected.

@AndyM48
Copy link
Contributor Author

AndyM48 commented Sep 23, 2021

This may be interesting:
https://pypi.org/project/code128/

@AndyM48
Copy link
Contributor Author

AndyM48 commented Sep 23, 2021

It is very difficult to know how to make a barcode which will work correctly, without having a scanner to try it out. I have looked at all the output of the various barcode programmes and I am no better off.

Since I cannot help with the python programming, perhaps you could add some code along these lines:

If {length(barcode_string} = 13}
then
create barcode with python-barcode EAN13
else
create barcode with python-barcode code128
fi
I can then test the results at one of our local shops.

Thanks

@joanisc
Copy link
Owner

joanisc commented Sep 23, 2021

Hi @FDServices. I know there is lots of work to do in the barcode part too. Now the system is only prepared for EAN13 type. If you put a bigger number...I think ¿it tries to round? I can control this if I have some time. I have no problem in using any other program that works, but I couldn't find an easy way to use barcode program inside the python script. I would like to correct what you are reporting by trying to guess the barcode type and letting the user choose the correct barcode type.

@AndyM48
Copy link
Contributor Author

AndyM48 commented Sep 23, 2021

and letting the user choose the correct barcode type.

I doubt that is the way forward. EAN13 seems to work for 13 digit codes. I am pretty sure that code128B is the other type we need, but we will simply have to try them out. It may be that the barcode scanners can actually cope with different types, we won't know until we try them. In my opinion we need to write some code which allows us to try each one in turn. If you can write the IF .. THEN..ELSE code outlined above then we can test python-barcode to see if that will be sufficient. If not we can then easily try something else.

@AndyM48
Copy link
Contributor Author

AndyM48 commented Sep 24, 2021

So I have had some fun with the code, but, since this is my first attempt at python programming, I am reluctant to make a pull request. The changes that I made are:
Line 7: "from barcode import EAN13,Code128"
Line 110: delete "codebarImg = EAN13(codebar, writer=ImageWriter())"
insert (I don't know how to preserve the spacing so I have replaced with > characters)
>> if len(codebar) > 13:
>>> codebarImg = Code128(codebar, writer=ImageWriter())
>> else:
>>> codebarImg = EAN13(codebar, writer=ImageWriter())
I also changed the dimensions of the barcode image to 600x150 which seems to work better with the longer codes.

Let me know if all this is, as I suspect, nonsense, but it may help.

I also realised why the 13 digit codes look strange when encoded by EAN13. It is because EAN13 includes a checkdigit (the leftmost digit) so python-barcode cleverly alters the last digit to correct the code. Ha Ha

@joanisc
Copy link
Owner

joanisc commented Sep 24, 2021

Hi @FDServices. I know there is lots of work to do in the barcode part too. Now the system is only prepared for EAN13 type. If you put a bigger number...I think ¿it tries to round? I can control this if I have some time. I have no problem in using any other program that works, but I couldn't find an easy way to use barcode program inside the python script. I would like to correct what you are reporting by trying to guess the barcode type and letting the user choose the correct one.

So I have had some fun with the code, but, since this is my first attempt at python programming, I am reluctant to make a pull request. The changes that I made are:
Line 7: "from barcode import EAN13,Code128"
Line 110: delete "codebarImg = EAN13(codebar, writer=ImageWriter())"
insert (I don't know how to preserve the spacing so I have replaced with > characters)
>> if len(codebar) > 13:
>>> codebarImg = Code128(codebar, writer=ImageWriter())
>> else:
>>> codebarImg = EAN13(codebar, writer=ImageWriter())

Yes. That was the idea. Something similar to this.

I also changed the dimensions of the barcode image to 600x150 which seems to work better with the longer codes.

I'm sure you know that when touching over an image, or barcode it is resized bigger on a new window. To be readed well. Right?

Let me know if all this is, as I suspect, nonsense, but it may help.

I also realised why the 13 digit codes look strange when encoded by EAN13. It is because EAN13 includes a checkdigit (the leftmost digit) so python-barcode cleverly alters the last digit to correct the code. Ha Ha.

Great. Thank you!

@joanisc
Copy link
Owner

joanisc commented Sep 24, 2021

I did a little change to address what you said about guessing the barcode type. If you wanna try... But IMHO maybe it will be not that easy and at the end we maybe have to let the user choose which barcode type.

@AndyM48
Copy link
Contributor Author

AndyM48 commented Sep 24, 2021

That looks pretty special ... let me try it out.

I did not understand your comment on the barcode image, but that can wait...

@AndyM48
Copy link
Contributor Author

AndyM48 commented Sep 25, 2021

We need to test out the barcodes before we can close this issue. I will get on with that asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants