Created
October 1, 2019 18:46
-
-
Save ccmorataya/3ffb2d74d876493627c44bc5241be1c1 to your computer and use it in GitHub Desktop.
replace the magenta pixels with transparency
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
# Original answer in https://stackoverflow.com/a/765774/6189341 | |
from PIL import Image | |
img = Image.open("area02_level_tiles.png") # CM:: replace area02_level_tiles.png with the name/path of the image to process | |
img = img.convert("RGBA") | |
datas = img.getdata() | |
newData = [] | |
for item in datas: | |
if item[0] == 255 and item[2] == 255: | |
newData.append((255, 255, 255, 0)) | |
else: | |
newData.append(item) | |
img.putdata(newData) | |
img.save("transparency.png", "PNG") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment