Reputation: 559
I'd like to perform an OR operation on two images using PIL/Pillow. Currently I'm doing something like this:
def image_union(figure1, figure2):
image1 = Image.open(figure1.visualFilename)
image2 = Image.open(figure2.visualFilename)
blended = Image.blend(image1, image2, .5)
output = ImageOps.grayscale(blended)
output.save('out-' + figure1.name + '-' + figure2.name + '.png')
return blended
I'd like to OR these two images:
but the above operation returns the following, whereas I would expect the two bottom circles attached to the star to be fully black:
Upvotes: 4
Views: 1394
Reputation: 308206
Use ImageChops.darker
instead of Image.blend
.
blended = ImageChops.darker(image1, image2)
Upvotes: 5