Created
January 31, 2015 13:26
-
-
Save hakatashi/c2a6eed45f7372e5016e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
omote = Image.open('omote.png', 'r') | |
ura = Image.open('ura.png', 'r') | |
dest = Image.new('RGBA', omote.size) | |
(width, height) = omote.size | |
for x in range(width): | |
for y in range(height): | |
omotepx = omote.getpixel((x, y))[0] | |
urapx = ura.getpixel((x, y))[0] | |
alpha = 255 + urapx - omotepx | |
if alpha == 0: | |
val = 255 | |
else: | |
val = 255 * urapx / alpha | |
dest.putpixel((x, y), (val, val, val, alpha)) | |
dest.save('dest.png', 'PNG') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment