Why does Pillow's ImageChop.multiply() not do the same thing as Photoshop's multiply?

160 Views Asked by At

Alternatively, how can I simulate this Photoshop affect programmatically?

In Photoshop, I have two layers:

A simple "Magenta" fill, with blend mode Multiply, and Opacity 100%

enter image description here

And a simple "Cyan" fill, with blend mode Multiply, and Opacity 50%

enter image description here

Which looks like this at 100% Opacity btw

enter image description here

The result is a nice 100% opacity purple:

enter image description here

I tried to do what I thought would be the same thing with Pillow:

from PIL import Image, ImageChops

path = './static/images/'
cyan = Image.open(path+'Cyan.png')
magenta = Image.open(path+'Magenta.png')

# set cyan to 50% opacity
cyan.putalpha(127)

# set magenta to 100% opacity
magenta.putalpha(255)

# blend mode multiply??
blend = ImageChops.multiply(magenta, cyan)

blend.save(path+'blend.png')

but the result is this:

enter image description here

Which, in Photoshop, this is what i get if I set BOTH Magenta and Cyan to 50%.

So, what is ImageChops doing differently from Photoshop here? and how can I do what I did in Photoshop.. but in Python? Is there a way to multiply blend two images but to take the higher opacity instead of the lower? Or should I be using some other method entirely?

0

There are 0 best solutions below