Skip to content

Commit

Permalink
Align the compression value for the PNG output
Browse files Browse the repository at this point in the history
  • Loading branch information
heuer committed Oct 26, 2023
1 parent 97e9269 commit 058d754
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sandbox/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
except ImportError:
qrcodegen = None


_PNG_COMPRESSION_LEVEL = 6 # Default Pillow PNG compression level


if qrcode:
def create_qrcode(data='QR Code Symbol'):
"""qrcode create 1-M"""
Expand Down Expand Up @@ -61,7 +65,8 @@ def png_qrcode(data='QR Code Symbol'):
"""qrcode PNG 1-M"""
qr = QRCode(error_correction=ERROR_CORRECT_M, box_size=10)
qr.add_data(data, optimize=False)
qr.make_image().save(os.path.join(_output_dir(), 'qrcode_%s.png' % data))
qr.make_image().save(os.path.join(_output_dir(), 'qrcode_%s.png' % data),
compress_level=_PNG_COMPRESSION_LEVEL)

if qrcodegen:
def create_qrcodegen(data='QR Code Symbol'):
Expand Down Expand Up @@ -114,7 +119,7 @@ def svg_segno(data='QR Code Symbol'):
def png_segno(data='QR Code Symbol'):
"""Segno PNG 1-M"""
segno.make_qr(data, error='m', boost_error=False).save(os.path.join(_output_dir(), 'segno_%s.png' % data), scale=10,
compresslevel=6)
compresslevel=_PNG_COMPRESSION_LEVEL)


def run_create_tests(which=None, number=200, table=None):
Expand Down

0 comments on commit 058d754

Please sign in to comment.