refactor access of private member _img of qrcode
Since version 2.5 python-qrcode allows the direct access of the PIL-functions. (We require version 4 and above). Thus, we can simply call qr_img.convert() without accessing the private member. This refactoring is identical in functionality.
This commit is contained in:
parent
e8d91a6735
commit
798893caee
|
@ -157,7 +157,7 @@ class Escpos(object):
|
||||||
if not native:
|
if not native:
|
||||||
# Map ESC/POS error correction levels to python 'qrcode' library constant and render to an image
|
# Map ESC/POS error correction levels to python 'qrcode' library constant and render to an image
|
||||||
if model != QR_MODEL_2:
|
if model != QR_MODEL_2:
|
||||||
raise ValueError("Invalid QR model for python-qrcode rendering (must be QR_MODEL_2)")
|
raise ValueError("Invalid QR model for qrlib rendering (must be QR_MODEL_2)")
|
||||||
python_qr_ec = {
|
python_qr_ec = {
|
||||||
QR_ECLEVEL_H: qrcode.constants.ERROR_CORRECT_H,
|
QR_ECLEVEL_H: qrcode.constants.ERROR_CORRECT_H,
|
||||||
QR_ECLEVEL_L: qrcode.constants.ERROR_CORRECT_L,
|
QR_ECLEVEL_L: qrcode.constants.ERROR_CORRECT_L,
|
||||||
|
@ -168,7 +168,8 @@ class Escpos(object):
|
||||||
qr_code.add_data(content)
|
qr_code.add_data(content)
|
||||||
qr_code.make(fit=True)
|
qr_code.make(fit=True)
|
||||||
qr_img = qr_code.make_image()
|
qr_img = qr_code.make_image()
|
||||||
im = qr_img.convert("RGB") # Convert the RGB image in printable image
|
im = qr_img._img.convert("RGB")
|
||||||
|
# Convert the RGB image in printable image
|
||||||
self.image(im)
|
self.image(im)
|
||||||
return
|
return
|
||||||
# Native 2D code printing
|
# Native 2D code printing
|
||||||
|
|
Loading…
Reference in New Issue