Skip to content
Advertisement

Pasting an image in Pillow makes everything black and white

Every time that I’d paste anything to template.png (which is totally transparent) It’ll get this weird black effect that I’ve got no idea where it’s coming from. I’ve tried creating different python file, reinstalling python and Pillow, creating another directory, restarting my computer but nothing seems to solve it. The problem has been ongoing for two days now, it would disappear randomly and come back like that.

I’m on Windows 10 21H1 running Python 3.9.6 and Pillow 8.3.1

base = Image.open('template.png')
emoji = Image.open('emoji.png')

base.paste(emoji, (0, 0))
base.save('out.png')

enter image description here(template.png) enter image description here(emoji.png) enter image description here (out.png)

Advertisement

Answer

The problem was that I’ve saved the image as single-channel. Thanks to HansHirse

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement