#!/usr/bin/python3
# ===================================================================
# from: www.youtube.com/watch?v=SqVvm3QiQVk
# -------------------------------------------------------------------
# pip install qrcode
# pip install pyzbar
# pip install pillow
# -------------------------------------------------------------------
# ---- simple way
# img = qrcode.make(qr_data)
# img.save('my_qrcode.png')
# ===================================================================
qr_data = 'Don\'t forget my birthday'
qr_img = 'my_color_qrcode.png'
# ---- encoding -----------------------------------------------------
import qrcode
qr = qrcode.QRCode(version=1,box_size=10,border=5)
qr.add_data(qr_data)
qr.make(fit=True)
img = qr.make_image(fill_color='red',back_color='white')
img.save(qr_img)
print()
print(f'QR image: {qr_img}')
# ---- decoding -----------------------------------------------------
from pyzbar.pyzbar import decode
from PIL import Image
img = Image.open(qr_img)
results = decode(img)
print()
print(results)