misc: use binary files for thumbnails (#36515)
This commit is contained in:
parent
8c0658c2c3
commit
b46c654323
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue