Convert png to jpeg using Pillow
The issue with that image isn't that it's large, it is that it isn't RGB, specifically that it's an index image.
Here's how I converted it using the shell:
>>> from PIL import Image
>>> im = Image.open("Ba_b_do8mag_c6_big.png")
>>> im.mode
'P'
>>> im = im.convert('RGB')
>>> im.mode
'RGB'
>>> im.save('im_as_jpg.jpg', quality=95)
So add a check for the mode of the image in your code:
if not im.mode == 'RGB':
im = im.convert('RGB')
You should use convert() method:
from PIL import Image
im = Image.open("Ba_b_do8mag_c6_big.png")
rgb_im = im.convert('RGB')
rgb_im.save('colors.jpg')
more info: http://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.convert