Fix: images with a transparency layer now use a white background

This commit is contained in:
Philipp Klaus
2016-12-20 14:00:25 +01:00
parent a8fcd553de
commit 69ba25ee1a

View File

@@ -77,6 +77,10 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, **kwargs):
hsize = int((dots_printable[0] / im.size[0]) * im.size[1])
im = im.resize((dots_printable[0], hsize), Image.ANTIALIAS)
logger.warning('Need to resize the image...')
if 'A' in im.mode:
bg = Image.new("RGB", im.size, (255,255,255))
bg.paste(im, im.split()[-1])
im = bg
im = im.convert("L")
if im.size[0] < device_pixel_width:
new_im = Image.new("L", (device_pixel_width, im.size[1]), 255)