Resizing uploaded images based on a maximum width in django (PIL)

Posted by AndrewE on Stack Overflow See other posts from Stack Overflow or by AndrewE
Published on 2012-03-18T17:04:32Z Indexed on 2012/03/18 17:57 UTC
Read the original article Hit count: 149

Filed under:
|
|
|

I'm working on a simple message board app in Django that lets people upload images to be displayed in their posts. Since the div containing the posts is only 700px, I want to resize the uploaded images to a max width of something like 680px to save space rather than using css to display an image that's too large within the space constraints.

I've been searching this site, google and the PIL docs for a while and haven't found any way of resizing an image on one dimension while maintaining the original aspect ratio. Given my inexperience, it's possible that I'm just not recognizing a solution that's plain to someone who knows what to look for.

© Stack Overflow or respective owner

Related posts about django

Related posts about image