Created
May 8, 2014 18:06
-
-
Save george-silva/e788a75307eea1c30e33 to your computer and use it in GitHub Desktop.
red
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
#!/usr/bin/env python | |
import os | |
import sys | |
import Image | |
EXTENSIONS = ".jpg", ".jpeg", ".png", ".bmp", ".tif" | |
SIZE = 1024, 768 | |
def redimensionar_imagens(dir_): | |
for root, dirs, files in os.walk(dir_): | |
for file_ in files: | |
if file_.lower().endswith(EXTENSIONS): | |
path = os.path.join(root,file_) | |
try: | |
im = Image.open(path) | |
im.thumbnail(SIZE, Image.ANTIALIAS) | |
im.save(path) | |
except IOError as err: | |
print "[ERRO] ("+path+") "+err.strerror | |
if __name__ == "__main__": | |
dir_ = sys.argv[1] | |
redimensionar_imagens(dir_) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment