un1t / django-resized

Resizes image original to specified size. Compatible with sorl-thumbnail
260 stars 50 forks source link

JPEG images taken with iPhone after resize are rotated. #33

Open Bohooslav opened 3 years ago

Bohooslav commented 3 years ago

There are some JPEG images taken with iPhone that after I upload them in the Django admin they got rotated after resizing. I force JPEG format. Maybe because the rotation metadata isn't saved?

My model

image = ResizedImageField('Головне фото', size=[1024, 1024], upload_to='images')

My settings

DJANGORESIZED_DEFAULT_SIZE = [1920, 1080]
DJANGORESIZED_DEFAULT_QUALITY = 75
DJANGORESIZED_DEFAULT_KEEP_META = True
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'JPEG'
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'JPEG': ".jpg"}
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True

The photo for example I have attached.

IMG_2325

After upload the photo got rotated(90deg). Here is what happened to it. image

Gagaro commented 3 years ago

Hi, thanks for the report.

There's probably something to be done here: https://github.com/un1t/django-resized/blob/master/django_resized/forms.py#L21-L57

Feel free to make a PR if you end up fixing this.

Bohooslav commented 3 years ago

I have never been fixing anything like that. Is there any README.md with instructions about the setup and development? It would help me a lot. Thanks)

Gagaro commented 3 years ago

Not really.

You have the instructions to run the test in the README.

But then I'm not sure how to unit test that. You should probably just fork the repository and install it with pip install -e git@github.com:bohooslav/django-resized.git in your Django project so you can update it and test your modification directly.

Then once you have fix it you can commit / push and open the pull request.

Bohooslav commented 3 years ago

I am noob to do that myself. Sorry.

Gagaro commented 3 years ago

Don't worry, reporting it is already a huge help :wink: .

Bohooslav commented 3 years ago

Thanks.

al-hadi commented 3 years ago

Experiencing this also

al-hadi commented 3 years ago

Ended up using django-imagekit with the Transpose() processor which does the trick

Akhilkokani commented 2 years ago

In your settings.py try setting DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = False and check if problem persists.

bob-koertge commented 2 years ago

In your settings.py try setting DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = False and check if problem persists.

I had an android image that was having the same rotation issue. This did fix it for me.