im = Image.open("audacious.png") rgb_im = im.convert('RGB') rgb_im.save('audacious.jpg')
from PIL import Image img = Image.open('image.png').convert('LA') img.save('greyscale.png')
LA
mode has luminosity (brightness) and alpha. If you use LA
mode, then greyscale.png
will be an RGBA image with the alpha channel of image.png
preserved. If you use L
mode, then greyscale.png
will be an RGB image (with no alpha).
References
https://stackoverflow.com/questions/48248405/cannot-write-mode-rgba-as-jpeg
https://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python