-
-
Save ShalbafZadeh/9042026 to your computer and use it in GitHub Desktop.
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
''' | |
Created on Sep 15, 2013 | |
@author: Mohammad reza Kamalifard | |
''' | |
import Image | |
import sys | |
im = Image.open(sys.argv[1]) | |
hSize, wSize = im.size | |
print 'Size of your image height is %d and width is %d'% (hSize, wSize) | |
print 'You can change Your image size with changing height of your photo and width is change automaticlly to maintain its aspect ratio?' | |
newHeight = float(raw_input('Please enter new height : ')) | |
newWidth = wSize / (hSize / newHeight) | |
print newHeight, newWidth | |
answer = raw_input('This operation will replace and modify your image ! Do you want to change size? (Y, N) \n') | |
if answer.lower() == 'y': | |
im = im.resize((int(newHeight), int(newWidth))) | |
index = sys.argv[1].lower().find('.jpg') | |
file_name = sys.argv[1][:index] | |
im.save(file_name + 'resized.jpg') | |
elif answer.lower() == 'n': | |
sys.exit() | |
else: | |
print 'Please enter Y or N!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment