Last active
January 8, 2016 02:35
-
-
Save guyoun/8e54dd35edc19ebab441 to your computer and use it in GitHub Desktop.
Merge two images using PIL
This file contains 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 | |
img = Image.new("RGBA", (400,570)) | |
bg = Image.open("./s3.png") | |
fg = Image.open("./p1.png") | |
img.paste(bg, (0,0),bg) | |
img.paste(fg, (0,0),fg) | |
bg.paste(fg, (0, 0), fg) | |
img_alpha = Image.alpha_composite(bg,fg) | |
img.save("./merge.png") | |
bg.save("./bg-merge.png") | |
img_alpha.save("./alpha-merge.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment