oostendo / python-zxing

python wrapper for the ZXing barcode library
http://code.google.com/p/zxing
273 stars 103 forks source link

how to take bytes as input instead of image path? #23

Open CRonaldo1997 opened 6 years ago

CRonaldo1997 commented 6 years ago

As described in the README, reader.decode() takes image path as parameter: reader = zxing.BarCodeReader("/var/opt/zxing") barcode = reader.decode("/tmp/image.jpg")

How to take bytes instead of image path? For example: with open('/tmp/image.jpg','rb') as img_file: img_bytes = img_file.read() barcode = reader.decode(img_bytes)

Thanks!

jgtjerry commented 5 years ago

Were you able to solve this?

whc2001 commented 4 years ago

I don't think it's possible. Take a look at the code and you'll find it just calls zxing package from the command line. You will have to write the stream into a temporary file first.