Project
Function
Sample CLI
gway qr generate-image
References
['resource']
Full Code
def generate_image(value, *, path=None):
"""Generate a QR code image from the given value and save it to the specified path.
If path is not provided, we use a random uuid to name it, unrelated to the value.
"""
img = qrcode.make(value)
if path is None:
path = gw.resource("work", "shared", "qr_codes", str(uuid.uuid4()) + ".png")
os.makedirs(os.path.dirname(path), exist_ok=True)
img.save(path)
return path