pdf417decoder icon indicating copy to clipboard operation
pdf417decoder copied to clipboard

Cannot decode barcodes which are not padded

Open ihabunek opened this issue 3 years ago • 2 comments

I noticed that barcodes which don't have any padding cannot be decoded. I'm using the following code to test:

import sys
from PIL import Image
from pdf417decoder import PDF417Decoder

image = Image.open(sys.argv[1])
decoder = PDF417Decoder(image)

if decoder.decode() > 0:
    decoded = decoder.barcode_data_index_to_string(0)
    print(decoded)
else:
    print("cannot decode")

The following image cannot be decoded: invalid

While the following image can: valid

Images are the same, except that second image has 1px of white padding around the barcode, while the first image touches the image borders.

ihabunek avatar Jul 02 '22 13:07 ihabunek

Hi Ivan, would you be open to submitting a pull request that adds a 1px border to incoming images to resolve this issue?

We'll merge your PR and can release an update that has that fix incorporated.

jboarman avatar Jul 02 '22 17:07 jboarman

I added the padding here : https://github.com/sparkfish/pdf417decoder/pull/7

Looks like the left most of the image need to have single white line , otherwise the start-stop signature won't be detected and hence no barcode will be detected.

kwcckw avatar Jul 16 '22 04:07 kwcckw

This should be closed then right?

esnosy avatar Dec 01 '23 03:12 esnosy

This should be closed then right?

It should be resolved, did you facing any problem with it?

kwcckw avatar Dec 06 '23 07:12 kwcckw

I didn't I was just researching and found the open issue, and I think I found a commit or a pull request somewhere that fixes it

On Wed, Dec 6, 2023, 9:50 AM Kok Wei @.***> wrote:

This should be closed then right?

It should be resolved, did you facing any problem with it?

— Reply to this email directly, view it on GitHub https://github.com/sparkfish/pdf417decoder/issues/6#issuecomment-1842274960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGC6KLMX7KADTWP42BOJLGDYIAPVDAVCNFSM52PCXUP2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBUGIZDONBZGYYA . You are receiving this because you commented.Message ID: @.***>

esnosy avatar Dec 06 '23 08:12 esnosy

Yes, this pull request should be merged now: https://github.com/sparkfish/pdf417decoder/pull/7

kwcckw avatar Dec 06 '23 08:12 kwcckw

Yes, this pull request should be merged now: https://github.com/sparkfish/pdf417decoder/pull/7

Awesome, let's close this issue then 🙏

esnosy avatar Dec 06 '23 08:12 esnosy