Skip to content

Instantly share code, notes, and snippets.

@LordGhostX
Created October 26, 2019 19:36
Show Gist options
  • Save LordGhostX/da9dc3df89892cd7c883ccdb820eb0c1 to your computer and use it in GitHub Desktop.
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
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