Skip to content

Instantly share code, notes, and snippets.

@andreztz
Last active August 11, 2016 05:09
Show Gist options
  • Save andreztz/a8a4fc8cf81951c77840be9c9e597596 to your computer and use it in GitHub Desktop.
Save andreztz/a8a4fc8cf81951c77840be9c9e597596 to your computer and use it in GitHub Desktop.
"""
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