Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import qrcode
- from PIL import Image
- import os
- import base64
- welcomeCode = "0A1B2C"
- fileNamePng = "qr_" + welcomeCode + ".png"
- # create QR
- img = qrcode.make(welcomeCode)
- type(img) # qrcode.image.pil.PilImage
- # resize
- newImage = img.resize((73, 73))
- #save and reopen
- newImage.save(fileNamePng)
- with open(fileNamePng, "rb") as img_file:
- b64_string = base64.b64encode(img_file.read())
- print(b64_string.decode('utf-8'))
Add Comment
Please, Sign In to add comment