Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview generator rotating the image by 90 degrees clockwise while generating thumbnail #212

Closed
AbhijitKulkarni95 opened this issue Feb 11, 2021 · 8 comments
Labels
preview feature a new format or new option to a format preview

Comments

@AbhijitKulkarni95
Copy link

Preview generator rotating the image by 90 degrees clockwise while generating thumbnail

Original image:

original image

Generated thumbnail:

thumb

Please let me know if I have to change something.

Thanks in advance.

@inkhey
Copy link
Contributor

inkhey commented Feb 11, 2021

Hello, Thanks for using preview_generator.
The issue is related to exif rotation metadata. In fact the original image is in landscape but contain some exif rotation metadata, this way your browser is able to display your image in portrait mode.

In current state preview_generator doesn't look at theses metadata, so the rendered preview image:

  • doesn't contain exif rotation metadata
  • is not either hardly rotated to follow theses infos.

So the rendered image by preview_generator is not rotated the way, you expect.

There is already a pending issue about this:
#166
the proper way to solve this seems to replace exif rotation metadata in generated preview (to have same behavior).

@AbhijitKulkarni95
Copy link
Author

Hi, Thanks for the reply.

image

By adding image = ImageOps.exif_transpose(image) in image__Pillow.py I was able to resolve this issue.

Any idea if this is the right way?

@lebouquetin
Copy link
Member

the proper way to solve this seems to replace exif rotation metadata in generated preview (to have same behavior).

@inkhey way you write "replace exif rotation metadata", you mean "copy rotation metadata from original image to thumbnail one"? If so, it looks like this the right way for me too.

@inkhey inkhey added the preview feature a new format or new option to a format preview label Jun 28, 2021
@tonypottera24
Copy link

Any ideas of how to fix this when wand is used?

@AbhijitKulkarni95
Copy link
Author

Any ideas of how to fix this when wand is used?

No idea buddy.

@tonypottera24
Copy link

I followed your suggestions and add these code before I send files into PreviewManager

    try:
        with PILImage.open(image_path) as image:
            image = PILImageOps.exif_transpose(image)
        image.save(image_path)
    except Exception as e:
        print('not a image')
        print(e)

@AbhijitKulkarni95
Copy link
Author

I followed your suggestions and add these code before I send files into PreviewManager

    try:
        with PILImage.open(image_path) as image:
            image = PILImageOps.exif_transpose(image)
        image.save(image_path)
    except Exception as e:
        print('not a image')
        print(e)

You can upgrade Pillow. It is fixed in the latest version.
pip install Pillow==8.3.1

@inkhey
Copy link
Contributor

inkhey commented Jan 18, 2022

Image rotation has been introduced by #274
About the fact we should probably keep exif instead of rotating image itself, there is a ticket here : #166

@inkhey inkhey closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview feature a new format or new option to a format preview
Projects
None yet
Development

No branches or pull requests

4 participants