question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decoding on MacOS gives raw data

See original GitHub issue

Hi,

Executing the following code gives me unexpected results on MacOS:

from pystrich.datamatrix import DataMatrixEncoder
import PIL
from io import BytesIO
from pylibdmtx.pylibdmtx import decode

data = 'SomeStringWithData'

print(f'Encoding: {data}')

image_bytes = DataMatrixEncoder(data).get_imagedata(cellsize=2)
image = PIL.Image.open(BytesIO(image_bytes))

results = decode(image)

print('raw results:')
print(results)

Output on MacOS 10.13.3:

Encoding: SomeStringWithData
raw results:
[Decoded(data=b'TpnfTusjohXjuiEbub\xb9AE\xbf}\xad|\xc81\xda\x9d\x9a\x95\xb2`\xf7`\x07\x01', rect=Rect(left=3, top=4, width=37, height=35))]

Whereas this works as expected on both Linux and Windows.

Basically it gives the raw data of the datamatrix instead of the parsed/decoded one.

I can’t figure out whats going on because:

  • dmtxread from dmtx-utils DOES work on the same machine, suggesting the c library IS NOT at fault here
  • the dmtxDecodeMatrixRegion wrapper function gives the wrong result, suggesting the c library IS at fault.

I’ve also tried having the latest version of libdmtx compiled from source on my search path instead of the one from homebrew but it gives the same result.

Is this a known issue on your end maybe?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
quicklizard99commented, Feb 16, 2019

Included in v.0.1.8, now on PyPI.

2reactions
jbwestoncommented, Nov 15, 2018

I have investigated a little more deeply and have come to the following conclusions:

  1. This is not a platform-dependent bug
  2. This is a problem with pylibdmtx, not the upstream library

Evidence

This is not a platform independent bug

I have managed to replicate this problem on my machine (Debian testing) with the apt installed libdmtx (v0.7.5), as has @akhmerov.

This is a problem with pylibdmtx

I used the first part of @justinvdk’s script above to generate a problematic datamatrix. I then saved this to a PNG file and read it in using the dmtxread program installed with apt, which is linked against libdmtx v0.7.5, and it produces the correct result.

What’s the problem

I believe that the API to libdmtx has changed between 2 bugfix releases, when really there should have been a minor (or even major) version release.

I used the shell script from this gist with git bisect in the libdmtx repo to find that this commit is where things stopped working. I notice that this commit actually changed the API of libdmtx by adding extra fields to some of the exported datastructures. This means that the wrappers in wrapper.py are formally incorrect, and things break in unexpected ways.’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot decode raw data “download problem”
I've updated and restarted my Mac, checked network, & retried multiple times. I also switched the destination, and allowed unrecognized sites ...
Read more >
Safari - cannot decode raw data - Help & Support
Hi everyone, some of my users report they get an "cannot decode raw data" error when they try to access my new 4.5...
Read more >
eidenv -p work but with segmentation fault on macOS #1220
We try to get informations from Belgium eid cards by using eidenv -p . The result is quite good as it displays all...
Read more >
Download X Lossless Decoder for Mac | MacUpdate
X Lossless Decoder(XLD) is a tool for Mac OS X that is able to decode/convert/play various 'lossless' audio files. The supported audio files ......
Read more >
macOS Command - "base64" - Herong's Tutorial Examples
Data Encoding Tutorials - Herong's Tutorial Examples. ∟Base64 Encoding and Decoding Tools. ∟macOS Command - "base64". This section provides a tutorial ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found