Convert indexed images (GIF) to RGB (if printing in --red)

This commit is contained in:
Philipp Klaus
2017-09-19 12:54:49 +02:00
parent 610954f800
commit a15084ad02
+5 -1
View File
@@ -75,10 +75,14 @@ def create_label(qlr, image, label_size, threshold=70, cut=True, dither=False, c
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: if im.mode.endswith('A'):
# place in front of white background and get red of transparency
bg = Image.new("RGB", im.size, (255,255,255)) bg = Image.new("RGB", im.size, (255,255,255))
bg.paste(im, im.split()[-1]) bg.paste(im, im.split()[-1])
im = bg im = bg
elif red and im.mode != "RGB":
# Convert GIF ("P") etc. to RGB
im = im.convert("RGB")
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: