Prevent pillow from closing non-exclusive fps (#1121)

This commit is contained in:
Lonami Exo 2019-03-06 09:14:06 +01:00
parent ae8f1fed05
commit fcfebf75a3

View File

@ -44,7 +44,9 @@ def _resize_photo_if_needed(
file = io.BytesIO(file)
try:
with PIL.Image.open(file) as image:
# 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)
if image.width <= width and image.height <= height:
return file