Skip to content

Instantly share code, notes, and snippets.

@omargourari
Created June 23, 2020 11:31
Show Gist options
  • Save omargourari/7c177261c72b28e2a1ef1a943b7c100d to your computer and use it in GitHub Desktop.
Save omargourari/7c177261c72b28e2a1ef1a943b7c100d to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import os
from PIL import Image
def change_color(image):
if not image.startswith('.') and len(os.path.basename(image)) < 18:
picture = Image.open(image)
w, h = picture.size
pixels = picture.load()
for x in range(w):
for y in range(h):
current_color = picture.getpixel((x, y))
(r, g, b, o) = current_color
if 153 <= r <= 252:
pixels[x, y] = (255, 255, 255, 255)
os.remove(image)
picture.save(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment