Skip to content

Instantly share code, notes, and snippets.

@jbweston
Created November 15, 2018 14:46
Show Gist options
  • Save jbweston/3eb6b2cd06f804bc5e5e6901e758ba50 to your computer and use it in GitHub Desktop.
Save jbweston/3eb6b2cd06f804bc5e5e6901e758ba50 to your computer and use it in GitHub Desktop.
Test for compatibility between pylibdmtx and libdmtx
#!/bin/bash
export LD_LIBRARY_PATH=$(pwd)/.libs
make -j8 2>/dev/null >/dev/null
if [ $? != 0 ]; then
exit 125
fi
python 2>/dev/null << EOF
from pystrich.datamatrix import DataMatrixEncoder
import PIL
from io import BytesIO
from pylibdmtx.pylibdmtx import decode
data = 'SomeStringWithData'
image_bytes = DataMatrixEncoder(data).get_imagedata(cellsize=2)
image = PIL.Image.open(BytesIO(image_bytes))
results, = decode(image)
assert results.data == data.encode(), (results.data, data.encode())
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment