Closed AbhijitKulkarni95 closed 2 years ago
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:
So the rendered image by preview_generator is not rotated the way, you expect.
There is already a pending issue about this: https://github.com/algoo/preview-generator/issues/166 the proper way to solve this seems to replace exif rotation metadata in generated preview (to have same behavior).
Hi, Thanks for the reply.
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?
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.
Any ideas of how to fix this when wand
is used?
Any ideas of how to fix this when
wand
is used?
No idea buddy.
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)
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
Image rotation has been introduced by https://github.com/algoo/preview-generator/pull/274 About the fact we should probably keep exif instead of rotating image itself, there is a ticket here : https://github.com/algoo/preview-generator/issues/166
Preview generator rotating the image by 90 degrees clockwise while generating thumbnail
Original image:
Generated thumbnail:
Please let me know if I have to change something.
Thanks in advance.