-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr_code.py
More file actions
31 lines (26 loc) · 876 Bytes
/
Copy pathqr_code.py
File metadata and controls
31 lines (26 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import qrcode
import qrcode.image.svg
from qrcode.image.styledpil import StyledPilImage
from qrcode.image.styles.moduledrawers.pil import RoundedModuleDrawer
from qrcode.image.styles.colormasks import SolidFillColorMask
def create_qr_code(url: str) -> StyledPilImage:
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=20,
border=2,
)
qr.add_data(url)
qr.make(fit=True)
img = qr.make_image(
image_factory=StyledPilImage,
module_drawer=RoundedModuleDrawer(),
color_mask=SolidFillColorMask(
back_color=(255, 255, 255),
front_color=(24, 29, 55),
),
)
return img
if __name__ == "__main__":
img_arxiv = create_qr_code("https://pintergreg.github.io/software-engineering/")
img_arxiv.save("../assets/qr_code.png")