logeyg
logeyg

Reputation: 559

OR operation of two two black and white images using PIL/Pillow

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:

enter image description here

enter image description here

but the above operation returns the following, whereas I would expect the two bottom circles attached to the star to be fully black:

enter image description here

Upvotes: 4

Views: 1394

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308206

Use ImageChops.darker instead of Image.blend.

blended = ImageChops.darker(image1, image2)

Upvotes: 5

Related Questions