I have a logo which I need to make into a monochrome version, for example all red. For example, convert this:
to this:
I've tried various techniques in PIL (mainly Image.paste), but the results do not honour the partially alpha transparent pixels around the edges.
from PIL import Image
image = Image.open('logo.png')
assert im.mode.endswith('A'), 'This will only work with images having alpha!'
image.load()
alpha = image.split()[-1]
image2 = Image.new(image.mode, image.size, (255, 0, 0, 0))
image2.putalpha(alpha)
image2.save('logo-red.png')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With