Django resizing an image pre save using PIL
- by Ed
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.