thumbnails png fix
couldn't generate thumbnails for png pictures due to different mode (RGBA vs RGB)
This commit is contained in:
parent
69fa5bb7c5
commit
49a521ea14
@ -33,6 +33,12 @@ def thumbnail(image, name, args):
|
|||||||
size = (450, 450)
|
size = (450, 450)
|
||||||
im = Image.open(image)
|
im = Image.open(image)
|
||||||
im.thumbnail(size)
|
im.thumbnail(size)
|
||||||
|
|
||||||
|
if (im.mode == 'RGBA'):
|
||||||
|
bg = Image.new('RGBA', im.size, (255,255,255))
|
||||||
|
composite = Image.alpha_composite(bg, im)
|
||||||
|
im=composite.convert('RGB')
|
||||||
|
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
im.save(output, format='JPEG')
|
im.save(output, format='JPEG')
|
||||||
im_data = output.getvalue()
|
im_data = output.getvalue()
|
||||||
|
Loading…
Reference in New Issue
Block a user