white_bg = Image.new('RGBA', image.size, (255, 255, 255, 255))
image = Image.alpha_composite(white_bg, image)
image = image.convert('RGB')
- if image_path.endwith('.png'):
+ if image_path.endswith('.png'):
# make sure png files are always RGB
# (it happened cmyk jpeg files were uploaded with a .png extension and that would fail)
image = image.convert('RGB')