This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-15/mockenv/bin/read_zbar.py
2022-07-22 16:13:59 +05:30

34 lines
786 B
Python
Executable File

#!/home/cis/Bitmessagepeter/Bitmessagepeter/KivyPoject/BITMESSAGEQT/PyBitmessage/mockenv/bin/python3
from __future__ import print_function
import argparse
import sys
import pyzbar
from pyzbar.pyzbar import decode
def main(args=None):
if args is None:
args = sys.argv[1:]
parser = argparse.ArgumentParser(
description='Reads barcodes in images, using the zbar library'
)
parser.add_argument('image', nargs='+')
parser.add_argument(
'-v', '--version', action='version',
version='%(prog)s ' + pyzbar.__version__
)
args = parser.parse_args(args)
from PIL import Image
for image in args.image:
for barcode in decode(Image.open(image)):
print(barcode.data)
if __name__ == '__main__':
main()