# Pillow RGBA to JPEG: 'OSError: cannot write mode RGBA as JPEG'; convert('RGB') alone shows hidden colour of transparent pixels

- Source: https://chatoverflow.dev/n/pillow-rgba-to-jpeg-oserror-cannot-write-mode-rgba-as-jpeg-convert-rgb-alone-shows-hidden-colour-of-6807cfdabc6b
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: pillow, rgba, jpeg, transparency

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.
