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

UPC-E encoding completely wrong information #119

Open
samymassoud opened this issue Dec 25, 2020 · 7 comments
Open

UPC-E encoding completely wrong information #119

samymassoud opened this issue Dec 25, 2020 · 7 comments

Comments

@samymassoud
Copy link

samymassoud commented Dec 25, 2020

Was trying to generate the UPC-E for the following number 12345687

The output image of the library as follows:

https://devtools360.com/en/barcode/generator

Which will read as 01891113 on the scanner
While the correct one is:

https://devtools360.com/en/barcode/generator

Something with the conversion to UPC-A and back to UPC-E must be wrong!

BTW: This nice library is part of the Online barcode generator , so thanks for the great effort.

@casperbakker
Copy link
Member

Hi Samy,

Could you provide the code you use to generate the barcode?

Note that UPC-E is only valid with 6-digits. It will add a zero in front and a checksum in the end to create a valid UPC-E barcode. If you provide 8 digits, it will try to create an EAN-8 code as it is almost the same structure but valid with 8 digits.

If you have arbitrary lengths, then don't use UPC-E but the general purpose Code128

@samymassoud
Copy link
Author

Hi Casper,

When I try 6 digits barcode it is not readable on any software scanner.

Here is an example.

123456 Barcode

Other alternatives will not allow less than 7 digits for the UPC-E

So tried the same, but still can't be scanned!

0123456
Same code on another alternative which can be scanned correctly!

other alternative same code

@casperbakker
Copy link
Member

Please provide the code you use to generate the barcode with this library, otherwise I have no place to start testing.

@samymassoud
Copy link
Author

Sure

$generator = new BarcodeGeneratorPNG();
$color = [0,0,0];
$code = "0123456";
$img_str = $generator->getBarcode($code, $generator::TYPE_UPC_E,2, 90, $color);
echo '<img src="data:image/png;base64,' . base64_encode($img_str). '">';

@oitowl7
Copy link

oitowl7 commented Jul 19, 2021

Has there been any movement or solutions on this. I am finding increasing numbers of UPC_E barcodes out in the wild and we currently are unable to create scannable barcodes for them.

Here is what we are currently doing. Note that I am currently hardcoding the 6 digit upc in. It is a real upc for Mountain Dew that is 01213405 and we are hardcoding in 121340 to be processed by the barcode generator and spit out a UPC_E.
`

    $value = "01213405";
    if (strlen($value) == 8) {
        $value = substr($value, 1, 6);
        $height = 72;
        // hardcoding upc string for now
        $svgData = $generator->getBarcode("121340", $generator::TYPE_UPC_E, 2, $height);
    }

`
This creates a barcode represented by this image:
Screenshot from 2021-07-19 11-42-58
This appears to be a UPC style barcode given that it has the 4 different sized bars but is not scannable by barcode apps and does not look like like the barcode that exists for that given 6 digit code, represented by this image which was gotten by putting in "0121340" into this website. This is the correct barcode and matches the one on the side of the actual packaging.
Screenshot from 2021-07-19 11-43-20
Trying to code it using EAN_8 does create a scannable barcode, but the barcode does not have the correct check value at the end (it creates it with a 9 for the check value). Passing the full 8 digit barcode using an EAN_8 type gives a "InvalidCheckDigitException" likely because for an EAN_8 to encode properly, it needs to be a 9.

We are currently running this in version 2.0.0

@Bernhard-Krop
Copy link
Contributor

I figured out that the implemented UPC-E barcode is only working with UPC-A codes as input (properly converting them into UPC-E), but not with proper UPC-E codes as input. I started working on a solution for this issue.

@Bernhard-Krop
Copy link
Contributor

@casperbakker , @samymassoud , @oitowl7

I've provided a pull request for this issue. Once merged into the main branch, it should fix all your problems. Please, let me know if you have still problems with barcode type UPC-E.

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

No branches or pull requests

4 participants