aaronspindler / RoomScout

A web app for finding and managing roommates
https://www.roomscout.ca
MIT License
32 stars 5 forks source link

Room Image JPG taken with cell phone have wrong orentation #31

Closed aaronspindler closed 4 years ago

aaronspindler commented 4 years ago

This is a breaking issue, I will include a sample file that

aaronspindler commented 4 years ago

IMG-5178

Uploading this file above when opened results in an image that looks like this below

image

aaronspindler commented 4 years ago

A couple of things I have found on the issue at: https://github.com/joelvarma/django-image-exif-rotation/blob/master/posts/models.py

and

https://www.edureka.co/community/17558/python-aws-boto3-how-do-i-read-files-from-s3-bucket

aaronspindler commented 4 years ago

This can be helpful to figure out how to edit image then saved it to S3 https://discuss.hellowebapp.com/t/pillow-resizing-images-thumbnail-on-amazon-s3/460/2

aaronspindler commented 4 years ago

This issue is being caused by EXIF data in the image that is there when shot on a mobile phone. The solution to this is a multi step process.

  1. Load image from user
  2. Send image data to Pillow
  3. Manipulate image in Pillow if EXIF data exists
  4. Save Pillow image in S3
  5. Make sure model updates with Image data
aaronspindler commented 4 years ago

https://stackoverflow.com/questions/51763488/how-to-rotate-image-before-save-in-django