Last active
August 11, 2016 05:09
-
-
Save andreztz/a8a4fc8cf81951c77840be9c9e597596 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
""" | |
http://pillow.readthedocs.io/en/3.2.x/handbook/tutorial.html | |
""" | |
from os import listdir | |
from subprocess import run | |
from subprocess import PIPE | |
from subprocess import check_output | |
from PIL import Image | |
files = listdir('.') | |
size = (96, 96) | |
start_len = len(files) | |
def remove(file): | |
cmd = ['rm', '{}'.format(file)] | |
out = run( | |
cmd, | |
stdout=PIPE, | |
stderr=PIPE, | |
universal_newlines=True | |
) | |
print('file {} done!'.format(file)) | |
return out | |
for i in range(len(files)): | |
try: | |
im = Image.open(files[i]) | |
if im.size == size: | |
# print(im.size) | |
# im.show() | |
out = remove(im.filename) | |
im.close() | |
print(out.stdout) | |
except Exception as err: | |
print(err) | |
print('-> {}'.format(start_len)) | |
print('-> {}'.format(len(listdir('.')))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment