Skip to content

Instantly share code, notes, and snippets.

@rezkam
Last active August 29, 2015 14:03
Show Gist options
  • Save rezkam/9bb328b4b8bed9c9036a to your computer and use it in GitHub Desktop.
Save rezkam/9bb328b4b8bed9c9036a to your computer and use it in GitHub Desktop.
dciw2.py
'''
----
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