Skip to content

Instantly share code, notes, and snippets.

@GordonOus
Created September 16, 2021 08:02
Show Gist options
  • Save GordonOus/59fca5ca60689e2c99c71a4217868f6f to your computer and use it in GitHub Desktop.
Save GordonOus/59fca5ca60689e2c99c71a4217868f6f to your computer and use it in GitHub Desktop.
import numpy as np
from PIL import Image
img1 = Image.open('lemur.png')
img2 = Image.open('flag.png')
n1 = np.array(img1)*255
n2 = np.array(img2)*255
#our images have a mode of RGB which is assumed to be an 8-bit int
n_image = np.bitwise_xor(n1, n2).astype(np.uint8)
#Convert to PIL image and save
Image.fromarray(n_image).save('n.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment