Created
October 26, 2019 19:36
-
-
Save LordGhostX/da9dc3df89892cd7c883ccdb820eb0c1 to your computer and use it in GitHub Desktop.
Python Script that removes a specified color from an image making it transparent
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 | |
img = Image.open("pic.png") | |
img = img.convert("RGBA") | |
pixel_data = img.load() | |
width, height = img.size | |
for y in range(height): | |
for x in range(width): | |
if pixel_data[x, y] == (255, 255, 255, 255): | |
pixel_data[x, y] = (255, 255, 255, 0) | |
img.save("pic-2.png", "PNG") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment