Created
September 21, 2020 19:17
-
-
Save aliyevorkhan/fe0526e951d28ecbbdda385e59963cd7 to your computer and use it in GitHub Desktop.
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
import os | |
from PIL import Image | |
def has_transparency(img): | |
if img.mode == "P": | |
transparent = img.info.get("transparency", -1) | |
for _, index in img.getcolors(): | |
if index == transparent: | |
return True | |
elif img.mode == "RGBA": | |
extrema = img.getextrema() | |
if extrema[3][0] < 255: | |
return True | |
return False | |
for file in os.listdir(os.getcwd()+'/Neutral'): | |
img = Image.open(os.getcwd()+'/Neutral/'+file) | |
if (has_transparency(img)): | |
os.remove(os.getcwd()+'/Neutral/'+file) | |
print('deleted') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment