Also use transparency fix from 69ba25e for die-cut labels

This commit is contained in:
Philipp Klaus
2016-12-22 23:22:28 +01:00
parent 69ba25ee1a
commit a4dc9e89f3
+5 -4
View File
@@ -70,6 +70,11 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, **kwargs):
else: else:
raise NotImplementedError("The image argument needs to be an Image() instance or the filename to an image.") raise NotImplementedError("The image argument needs to be an Image() instance or the filename to an image.")
if 'A' in im.mode:
bg = Image.new("RGB", im.size, (255,255,255))
bg.paste(im, im.split()[-1])
im = bg
if label_specs['kind'] == ENDLESS_LABEL: if label_specs['kind'] == ENDLESS_LABEL:
if rotate != 'auto' and int(rotate) != 0: if rotate != 'auto' and int(rotate) != 0:
im = im.rotate(int(rotate), expand=True) im = im.rotate(int(rotate), expand=True)
@@ -77,10 +82,6 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, **kwargs):
hsize = int((dots_printable[0] / im.size[0]) * im.size[1]) hsize = int((dots_printable[0] / im.size[0]) * im.size[1])
im = im.resize((dots_printable[0], hsize), Image.ANTIALIAS) im = im.resize((dots_printable[0], hsize), Image.ANTIALIAS)
logger.warning('Need to resize the image...') 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") im = im.convert("L")
if im.size[0] < device_pixel_width: if im.size[0] < device_pixel_width:
new_im = Image.new("L", (device_pixel_width, im.size[1]), 255) new_im = Image.new("L", (device_pixel_width, im.size[1]), 255)