mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-13 07:55:48 +03:00
parent
9a6bc5ae72
commit
320ab75818
|
@ -53,6 +53,11 @@ 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)
|
||||
try:
|
||||
kwargs = {'exif': image.info['exif']}
|
||||
except KeyError:
|
||||
kwargs = {}
|
||||
|
||||
if image.width <= width and image.height <= height:
|
||||
return file
|
||||
|
||||
|
@ -72,7 +77,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', **kwargs)
|
||||
buffer.seek(0)
|
||||
return buffer
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user