Merge pull request #3009 from initOS/8.0-fix_escpos_with_non_rgba_image

Bug: Exception when printing POS receipt via hardware proxy
This commit is contained in:
Frédéric Van der Essen 2014-12-01 15:55:17 +01:00
commit 02bdbee088
1 changed files with 6 additions and 1 deletions

View File

@ -442,7 +442,12 @@ class Escpos:
f.seek(0)
img_rgba = Image.open(f)
img = Image.new('RGB', img_rgba.size, (255,255,255))
img.paste(img_rgba, mask=img_rgba.split()[3])
channels = img_rgba.split()
if len(channels) > 1:
# use alpha channel as mask
img.paste(img_rgba, mask=channels[3])
else:
img.paste(img_rgba)
print 'convert image'