Skip to content

Commit

Permalink
export, add ability for exporting to PIL image or file
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoee committed Jul 17, 2020
1 parent 62b33a2 commit 30cae1e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions promptpay/qrcode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import crc16
import qrcode

ID_PAYLOAD_FORMAT = '00'
ID_POI_METHOD = '01'
Expand Down Expand Up @@ -89,3 +90,15 @@ def generate_payload(id="", amount=0):
data.append(format(ID_CRC, checksum(data2crc)))

return ''.join(data)


def to_image(payload=""):
img = qrcode.make(payload)
return img


def to_file(payload="", filepath=""):
imgfile = open(filepath, 'wb')
img = to_image(payload)
img.save(imgfile, 'PNG')
imgfile.close()

0 comments on commit 30cae1e

Please sign in to comment.