mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-30 17:59:55 +03:00
Added saving of exif image data when resizing it using pillow. This allows you load images with proper orientation. Not only landscape but also portrait.
This commit is contained in:
parent
acd4c8648e
commit
cc9537bb78
|
@ -53,6 +53,7 @@ def _resize_photo_if_needed(
|
|||
# Don't use a `with` block for `image`, or `file` would be closed.
|
||||
# See https://github.com/LonamiWebs/Telethon/issues/1121 for more.
|
||||
image = PIL.Image.open(file)
|
||||
exif = image.info['exif']
|
||||
if image.width <= width and image.height <= height:
|
||||
return file
|
||||
|
||||
|
@ -72,7 +73,7 @@ def _resize_photo_if_needed(
|
|||
result.paste(image, mask=image.split()[alpha_index])
|
||||
|
||||
buffer = io.BytesIO()
|
||||
result.save(buffer, 'JPEG')
|
||||
result.save(buffer, 'JPEG', exif=exif)
|
||||
buffer.seek(0)
|
||||
return buffer
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user