misc: handle PIL SyntaxError when thumbnailing (#49457)
This commit is contained in:
parent
fbadefbba6
commit
a8fd8136c6
|
@ -656,7 +656,13 @@ def get_thumbnail(filepath, content_type=None):
|
|||
elif orientation == 8:
|
||||
image = image.rotate(90, expand=1)
|
||||
|
||||
image.thumbnail((500, 300))
|
||||
try:
|
||||
image.thumbnail((500, 300))
|
||||
except SyntaxError:
|
||||
# PIL can raise syntax error on broken PNG files
|
||||
# * File "PIL/PngImagePlugin.py", line 119, in read
|
||||
# * raise SyntaxError("broken PNG file (chunk %s)" % repr(cid))
|
||||
raise IOError
|
||||
image_thumb_fp = BytesIO()
|
||||
image.save(image_thumb_fp, "PNG")
|
||||
except IOError:
|
||||
|
|
Loading…
Reference in New Issue