Skip to content

Instantly share code, notes, and snippets.

@phanatagama
Last active September 10, 2020 12:07
Show Gist options
  • Save phanatagama/45cf854608c16b3b585dd45ab4658834 to your computer and use it in GitHub Desktop.
Save phanatagama/45cf854608c16b3b585dd45ab4658834 to your computer and use it in GitHub Desktop.
Decode QR Code Image

Usage : python QReader.py <image>

Requirements:

  • Pyzbar
  • Pillow

Copyright @ Phanatagama

from PIL import Image
from pyzbar.pyzbar import decode
import sys
def decodeQR(file):
return decode(Image.open(file))[0][0].decode('utf-8')
def main():
try:
if len(sys.argv) > 1:
print("[*] Message :",decodeQR(sys.argv[1]))
else:
print('[!] Usage : python {} <image>'.format(sys.argv[0]))
except:
print("[!] Failed : your image isn't valid")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment