Last active
August 29, 2015 14:03
-
-
Save rezkam/9bb328b4b8bed9c9036a to your computer and use it in GitHub Desktop.
dciw2.py
This file contains hidden or 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
''' | |
---- | |
dciw2.py | |
---- | |
Copyright @itmard | |
------ | |
usage | |
create directory for all picture | |
replace dir with full path to picture directory | |
$python dciw2.py | |
''' | |
import Image | |
import os | |
dir = '/home/reza/Desktop/lug' | |
list_of_all = os.listdir(dir) | |
for i in list_of_all: | |
im = Image.open(dir + '/' + i) | |
hSize, wSize = im.size | |
if hSize == 5472: | |
newHeight = float(1200) | |
newWidth = wSize / (hSize / newHeight) | |
im = im.resize((int(newHeight), int(newWidth))) | |
index = i.lower().find('.jpg') | |
file_name = i[:index] | |
im.save(file_name + 'resized.jpg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment