Skip to content

Commit

Permalink
Allow setting QR code error correction level and make it higher by de…
Browse files Browse the repository at this point in the history
…fault.
  • Loading branch information
Carifio24 committed Jan 12, 2025
1 parent 05dde85 commit 33827bc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions glue_ar/common/qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def get_local_ip():
return IP


def create_qr(url, with_logo=True, color=GLUE_RED):
qr = segno.make_qr(url)
def create_qr(url, with_logo=True, color=GLUE_RED, error_level="H"):
qr = segno.make_qr(url, error=error_level)

Check warning on line 27 in glue_ar/common/qr.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/common/qr.py#L27

Added line #L27 was not covered by tests
out = BytesIO()
qr.save(out, kind="png", scale=7, dark=color, light="white")
qr.save(out, kind="png", scale=10, dark=color, light="white")

Check warning on line 29 in glue_ar/common/qr.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/common/qr.py#L29

Added line #L29 was not covered by tests
out.seek(0)
img = Image.open(out)
img = img.convert("RGB")
Expand All @@ -35,7 +35,7 @@ def create_qr(url, with_logo=True, color=GLUE_RED):
logo_max_size = height // 3
logo_img = Image.open(GLUE_LOGO)
# Resize the logo to logo_max_size
logo_img.thumbnail((logo_max_size, logo_max_size), Image.Resampling.LANCZOS)
logo_img.thumbnail((logo_max_size, logo_max_size), resample=Image.Resampling.LANCZOS)

Check warning on line 38 in glue_ar/common/qr.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/common/qr.py#L38

Added line #L38 was not covered by tests
# Calculate the center of the QR code
box = ((width - logo_img.size[0]) // 2, (height - logo_img.size[1]) // 2)
img.paste(logo_img, box)
Expand Down

0 comments on commit 33827bc

Please sign in to comment.