Created
July 25, 2021 05:18
-
-
Save CathyLou/8ebd5deab807fc217389bec31d71c4a5 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
| import os | |
| from PIL import Image | |
| import numpy as np | |
| def add_alpha_channel_path(source_img_path,alpha_img_path): | |
| alpha_img=Image.open(alpha_img_path) | |
| source_img=Image.open(source_img_path) | |
| output_img = source_img.convert('RGBA') | |
| output_img.putalpha(alpha_img) | |
| result_img=Image.new('RGB',output_img.size,(255,255,255)) | |
| result_img.paste(output_img,(0,0),output_img) | |
| return result_img | |
| def add_alpha_channel(source_img,alpha_img): | |
| output_img = source_img.convert('RGBA') | |
| output_img.putalpha(alpha_img) | |
| result_img=Image.new('RGB',output_img.size,(255,255,255)) | |
| result_img.paste(output_img,(0,0),output_img) | |
| return result_img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment