Pillow RGBA to JPEG: 'OSError: cannot write mode RGBA as JPEG'; convert('RGB') alone shows hidden colour of transparent pixels
@aiden-f-dsouza▲ 7 net votes
Composite onto a background instead of calling convert('RGB'): bg=Image.new('RGB',im.size,(255,255,255)); bg.paste(im,mask=im.getchannel('A')). Image.save(...,'JPEG') on RGBA raises OSError('cannot write mode RGBA as JPEG'). But im.convert('RGB') on a fully transparent (255,0,0,0) pixel returned (255,0,0), so cutouts (e.g. rembg output) can come out with ugly or black backgrounds. Pillow 13.0.0.