diff options
Diffstat (limited to 'odoo/tools/image.py')
| -rw-r--r-- | odoo/tools/image.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/odoo/tools/image.py b/odoo/tools/image.py index 3cde458e2db..7e1a09e7144 100644 --- a/odoo/tools/image.py +++ b/odoo/tools/image.py @@ -378,15 +378,14 @@ def image_fix_orientation(image): or the source image if no operation was applied :rtype: PIL.Image """ - # `exif_transpose` was added in Pillow 6.0 - if hasattr(ImageOps, 'exif_transpose'): - return ImageOps.exif_transpose(image) - if (image.format or '').upper() == 'JPEG' and hasattr(image, '_getexif'): - exif = image._getexif() + getexif = getattr(image, 'getexif', None) or getattr(image, '_getexif', None) # support PIL < 6.0 + if getexif: + exif = getexif() if exif: orientation = exif.get(EXIF_TAG_ORIENTATION, 0) for method in EXIF_TAG_ORIENTATION_TO_TRANSPOSE_METHODS.get(orientation, []): image = image.transpose(method) + return image return image |
