Created
April 8, 2014 17:46
-
-
Save mygeekdaddy/10162013 to your computer and use it in GitHub Desktop.
ImgResize
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
import Image, ImageOps, ImageFilter | |
import photos | |
import console | |
import clipboard | |
import datetime | |
img = photos.pick_image() | |
today = datetime.datetime.now() | |
# image = clipboard.get_image() | |
fileName = console.input_alert("Image Title", "Enter Image File Name") | |
fileName = fileName+'_'+today.strftime("%Y-%m-%d-%H%M%S") +'.png' | |
def customSize(img): | |
w, h = img.size | |
print 'w: ' + str(w) | |
print 'h: '+ str(h) | |
if w > 600: | |
wsize = 600/float(w) | |
print 'wsize: '+str(wsize) | |
hsize = int(float(h)*float(wsize)) | |
print 'hsize: ' + str(hsize) | |
img = img.resize((600, hsize), Image.ANTIALIAS) | |
return img | |
image = customSize(img) | |
# final = choose.resize((800,600),Image.ANTIALIAS) | |
saveit = photos.save_image(image) | |
if saveit is True: | |
print 'Resized image has been saved' | |
elif saveit is False: | |
print "Uh oh, not saved" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment