Parse max_width to int before compare

This commit is contained in:
Romain Porte 2017-05-22 23:16:25 +02:00
parent 14c7dfe58f
commit b60e540de5

View File

@ -101,12 +101,15 @@ class Escpos(object):
im = EscposImage(img_source)
try:
max_width = self.profile.profile_data['media']['width']['pixels']
max_width = int(self.profile.profile_data['media']['width']['pixels'])
if im.width > max_width:
raise ImageWidthError('{} > {}'.format(im.width, max_width))
except KeyError:
# If the printer's pixel width is not known, print anyways...
pass
except ValueError:
# If the max_width cannot be converted to an int, print anyways...
pass
if im.height > fragment_height:
fragments = im.split(fragment_height)