Skip to content

Instantly share code, notes, and snippets.

@rhybroy
Created April 27, 2012 12:13
Show Gist options
  • Save rhybroy/2508710 to your computer and use it in GitHub Desktop.
Save rhybroy/2508710 to your computer and use it in GitHub Desktop.
resize image by origin percent
import Image
basewidth = 300
img = Image.open(‘fullsized_image.jpg’)
wpercent = (basewidth / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
img.save(‘resized_image.jpg’)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment