only use alpha channel if it exists
This commit is contained in:
parent
8a9027edd1
commit
93dc416dd3
|
@ -438,7 +438,12 @@ class Escpos:
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
img_rgba = Image.open(f)
|
img_rgba = Image.open(f)
|
||||||
img = Image.new('RGB', img_rgba.size, (255,255,255))
|
img = Image.new('RGB', img_rgba.size, (255,255,255))
|
||||||
img.paste(img_rgba, mask=img_rgba.split()[3])
|
channels = img_rgba.split()
|
||||||
|
kwargs = {}
|
||||||
|
if len(channels) > 1:
|
||||||
|
# use alpha channel as mask
|
||||||
|
kwargs['mask'] = img_rgba.split()[3]
|
||||||
|
img.paste(img_rgba, **kwargs)
|
||||||
|
|
||||||
print 'convert image'
|
print 'convert image'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue