How do I resize an image using PIL and maintain its aspect ratio?
Define a maximum size. Then, compute a resize ratio by taking min(maxwidth/width, maxheight/height). The proper size is oldsize*ratio. There is of course also a library method to do this: the method Image.thumbnail.Below is an (edited) example from the PIL documentation.