-if open(infile, "rb").read(4) == b"%PDF":
- # extract QR code from PDF using hard-coded index, size and bit depth.
- # This will only work with the official Austrian green pass PDFs.
- pdf=PyPDF2.PdfFileReader(open(infile, "rb"))
- qr_img = pdf.getPage(0)['/Resources']['/XObject']['/Im3']
- qr_pil = Image.frombytes("1", (400,400), qr_img.getData())
-else: # assume image
- qr_pil = Image.open(infile)
+if infile:
+ if open(infile, "rb").read(4) == b"%PDF":
+ # extract QR code from PDF using hard-coded index, size and bit depth.
+ # This will only work with the official Austrian green pass PDFs.
+ pdf=PyPDF2.PdfFileReader(open(infile, "rb"))
+ qr_img = pdf.getPage(0)['/Resources']['/XObject']['/Im3']
+ qr_pil = Image.frombytes("1", (400,400), qr_img.getData())
+ else: # assume image
+ qr_pil = Image.open(infile)