Skip to content

Instantly share code, notes, and snippets.

@mygeekdaddy
Created April 8, 2014 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mygeekdaddy/10162013 to your computer and use it in GitHub Desktop.
Save mygeekdaddy/10162013 to your computer and use it in GitHub Desktop.
ImgResize
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