mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
upload: Fix logic for orientation when uploading avatars.
The previous logic was broken for an avatar without exif data.
This commit is contained in:
parent
3f0a1e7c54
commit
bbcdf8ca99
@ -85,9 +85,13 @@ name_to_tag_num = dict((name, num) for num, name in ExifTags.TAGS.items())
|
||||
|
||||
# https://stackoverflow.com/a/6218425
|
||||
def exif_rotate(image: Image) -> Image:
|
||||
if hasattr(image, '_getexif') is False:
|
||||
if not hasattr(image, '_getexif'):
|
||||
return image
|
||||
exif_dict = dict(image._getexif().items())
|
||||
exif_data = image._getexif()
|
||||
if exif_data is None:
|
||||
return image
|
||||
|
||||
exif_dict = dict(exif_data.items())
|
||||
orientation = exif_dict.get(name_to_tag_num['Orientation'])
|
||||
|
||||
if orientation == 3:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user