Django resizing an image pre save using PIL

Posted by Ed on Stack Overflow See other posts from Stack Overflow or by Ed
Published on 2010-04-17T12:42:29Z Indexed on 2010/04/17 12:53 UTC
Read the original article Hit count: 456

Filed under:
|
|
|

Ugh, I hate having to ask a question on such a common feature, but. . .

I'm using an ImageField in a form to upload a photo to S3. I want to resize the image before it is uploaded to S3. I'm trying to use PIL to test the dimensions and resize if necessary. The Image.open() part is throwing me though. It wants a filepath, and the ImageField from the form is only returning the actual file and filename. How can I resize the image before it's saved to S3?

Before we get to this point, I'm not using sorl because I believe sorl is compatible with models using ImageFields. But the model associated with the saved S3 images holds just the url of the image on S3 as opposed to using ImageFields.

© Stack Overflow or respective owner

Related posts about django

Related posts about image-resizing