misc: use binary files for thumbnails (#36515)

This commit is contained in:
Frédéric Péters 2019-11-15 21:42:17 +01:00
parent 8c0658c2c3
commit b46c654323
1 changed files with 2 additions and 2 deletions

View File

@ -569,7 +569,7 @@ def get_thumbnail(filepath, content_type=None):
except subprocess.CalledProcessError:
raise ThumbnailError()
else:
fp = open(filepath)
fp = open(filepath, 'rb')
try:
image = Image.open(fp)
@ -598,7 +598,7 @@ def get_thumbnail(filepath, content_type=None):
image = image.rotate(90, expand=1)
image.thumbnail((500, 300))
image_thumb_fp = StringIO()
image_thumb_fp = BytesIO()
image.save(image_thumb_fp, "PNG")
except IOError:
# failed to create thumbnail.