Skip to content

Instantly share code, notes, and snippets.

View RishiRatanPandey's full-sized avatar

Rishi RishiRatanPandey

  • India, Uttar Pradesh
View GitHub Profile
@tomvon
tomvon / resize-image-keep-aspect-ratio.py
Created June 8, 2014 22:59
Python script to resize an image while keeping the original aspect ratio.
#Resizes an image and keeps aspect ratio. Set mywidth to the desired with in pixels.
import PIL
from PIL import Image
mywidth = 300
img = Image.open('someimage.jpg')
wpercent = (mywidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))